You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/04/19 19:15:02 UTC

[GitHub] milleruntime commented on a change in pull request #435: Replace anonymous types with lambdas

milleruntime commented on a change in pull request #435: Replace anonymous types with lambdas
URL: https://github.com/apache/accumulo/pull/435#discussion_r182855383
 
 

 ##########
 File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
 ##########
 @@ -157,39 +156,36 @@ private static synchronized ExecutorService getThreadPool(Master master) {
       }
       if (servers.length > 0) {
         for (final String file : filesToLoad) {
-          results.add(executor.submit(new Callable<List<String>>() {
-            @Override
-            public List<String> call() {
-              List<String> failures = new ArrayList<>();
-              ClientService.Client client = null;
-              HostAndPort 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()
-                    .getTimeInMillis(Property.MASTER_BULK_TIMEOUT);
-                // Pair<String,Client> pair = ServerClient.getConnection(master, false,
-                // timeInMillis);
-                server = servers[random.nextInt(servers.length)].getLocation();
-                client = ThriftUtil.getTServerClient(server, master, timeInMillis);
-                List<String> attempt = Collections.singletonList(file);
-                log.debug("Asking " + server + " to bulk import " + file);
-                List<String> fail = client.bulkImportFiles(Tracer.traceInfo(), master.rpcCreds(),
-                    tid, tableId.canonicalID(), attempt, errorDir, setTime);
-                if (fail.isEmpty()) {
-                  loaded.add(file);
-                } else {
-                  failures.addAll(fail);
-                }
-              } catch (Exception ex) {
-                log.error("rpc failed server:" + server + ", tid:" + tid + " " + ex);
-              } finally {
-                ThriftUtil.returnClient(client);
+          results.add(executor.submit(() -> {
+            List<String> failures = new ArrayList<>();
+            ClientService.Client client = null;
+            HostAndPort 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()
+                  .getTimeInMillis(Property.MASTER_BULK_TIMEOUT);
+              // Pair<String,Client> pair = ServerClient.getConnection(master, false,
+              // timeInMillis);
 
 Review comment:
   Could remove commented code and format comments above nicely.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services