You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2019/02/19 18:08:06 UTC
[accumulo] branch master updated: Fix code quality issues found by
lgtm (#965)
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push:
new 010d0c8 Fix code quality issues found by lgtm (#965)
010d0c8 is described below
commit 010d0c819194944c8d5e3201f3b82a629778bda3
Author: Mike Walch <mw...@apache.org>
AuthorDate: Tue Feb 19 13:07:44 2019 -0500
Fix code quality issues found by lgtm (#965)
* Removed several cases where collections were
created and populated but never used
* Use equals() rather than == for Long equality
* Fixed log issue
---
.../org/apache/accumulo/server/fs/VolumeUtil.java | 7 +------
.../master/state/TabletStateChangeIterator.java | 4 ----
.../server/security/handler/ZKAuthorizor.java | 21 +--------------------
.../accumulo/server/util/LoginProperties.java | 11 -----------
.../master/tableOps/bulkVer1/LoadFiles.java | 3 ---
.../monitor/rest/status/StatusResource.java | 11 -----------
.../org/apache/accumulo/tserver/TabletServer.java | 2 +-
.../tserver/replication/AccumuloReplicaSystem.java | 3 +--
.../org/apache/accumulo/tserver/tablet/Tablet.java | 2 +-
9 files changed, 5 insertions(+), 59 deletions(-)
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
index e5d5f6e..164ffd1 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
@@ -123,13 +123,8 @@ public class VolumeUtil {
else
switchedPath = le.filename;
- ArrayList<String> switchedLogs = new ArrayList<>();
- String switchedLog = switchVolume(le.filename, FileType.WAL, replacements);
- if (switchedLog != null) {
- switchedLogs.add(switchedLog);
+ if (switchVolume(le.filename, FileType.WAL, replacements) != null) {
numSwitched++;
- } else {
- switchedLogs.add(le.filename);
}
if (numSwitched == 0) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java b/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
index 89cdcfa..4a3ee39 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
@@ -267,10 +267,6 @@ public class TabletStateChangeIterator extends SkippingIterator {
public static void setShuttingDown(IteratorSetting cfg, Set<TServerInstance> servers) {
if (servers != null) {
- List<String> serverList = new ArrayList<>();
- for (TServerInstance server : servers) {
- serverList.add(server.toString());
- }
cfg.addOption(SHUTTING_DOWN_OPTION, Joiner.on(",").join(servers));
}
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
index 0ff17b9..6ea8cda 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
@@ -19,21 +19,11 @@ package org.apache.accumulo.server.security.handler;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode;
-import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.RootTable;
import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.SystemPermission;
-import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.core.securityImpl.thrift.TCredentials;
import org.apache.accumulo.core.util.ByteBufferUtil;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
@@ -87,16 +77,7 @@ public class ZKAuthorizor implements Authorizor {
throws AccumuloSecurityException {
ZooReaderWriter zoo = context.getZooReaderWriter();
- // create the root user with all system privileges, no table privileges, and no record-level
- // authorizations
- Set<SystemPermission> rootPerms = new TreeSet<>();
- for (SystemPermission p : SystemPermission.values())
- rootPerms.add(p);
- Map<TableId,Set<TablePermission>> tablePerms = new HashMap<>();
- // Allow the root user to flush the metadata tables
- tablePerms.put(MetadataTable.ID, Collections.singleton(TablePermission.ALTER_TABLE));
- tablePerms.put(RootTable.ID, Collections.singleton(TablePermission.ALTER_TABLE));
-
+ // create the root user with no record-level authorizations
try {
// prep parent node of users with root username
if (!zoo.exists(ZKUserPath))
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java b/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java
index 13d9c32..0544afe 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java
@@ -16,10 +16,6 @@
*/
package org.apache.accumulo.server.util;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.TokenProperty;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
@@ -53,13 +49,6 @@ public class LoginProperties implements KeywordExecutable {
.loadClass(config.get(Property.INSTANCE_SECURITY_AUTHENTICATOR))
.asSubclass(Authenticator.class).newInstance();
- List<Set<TokenProperty>> tokenProps = new ArrayList<>();
-
- for (Class<? extends AuthenticationToken> tokenType : authenticator
- .getSupportedTokenTypes()) {
- tokenProps.add(tokenType.newInstance().getProperties());
- }
-
System.out
.println("Supported token types for " + authenticator.getClass().getName() + " are : ");
for (Class<? extends AuthenticationToken> tokenType : authenticator
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer1/LoadFiles.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer1/LoadFiles.java
index fb9bc83..21557d1 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer1/LoadFiles.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer1/LoadFiles.java
@@ -189,9 +189,6 @@ class LoadFiles extends MasterRepo {
}));
}
}
- Set<String> failures = new HashSet<>();
- for (Future<List<String>> f : results)
- failures.addAll(f.get());
filesToLoad.removeAll(loaded);
if (filesToLoad.size() > 0) {
log.debug("tid " + tid + " attempt " + (attempt + 1) + " " + sampleList(filesToLoad, 10)
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java
index f6a7119..b8d039d 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.monitor.rest.status;
-import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
@@ -24,8 +23,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import org.apache.accumulo.core.master.thrift.DeadServer;
-import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.monitor.Monitor;
import org.apache.accumulo.server.monitor.DedupedLogEvent;
import org.apache.accumulo.server.monitor.LogService;
@@ -64,15 +61,7 @@ public class StatusResource {
gcStatus = Status.ERROR;
}
- List<String> tservers = new ArrayList<>();
- for (TabletServerStatus up : Monitor.getMmi().tServerInfo) {
- tservers.add(up.name);
- }
- for (DeadServer down : Monitor.getMmi().deadTabletServers) {
- tservers.add(down.server);
- }
List<String> masters = Monitor.getContext().getMasterLocations();
-
masterStatus = masters.size() == 0 ? Status.ERROR : Status.OK;
int tServerUp = Monitor.getMmi().getTServerInfoSize();
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index 8a0c6a2..23b54b8 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -3085,7 +3085,7 @@ public class TabletServer implements Runnable {
}
future = new TServerInstance(entry.getValue(), key.getColumnQualifier());
} else if (cf.equals(TabletsSection.CurrentLocationColumnFamily.NAME)) {
- log.info("Tablet seems to be already assigned to {} {}",
+ log.info("Tablet seems to be already assigned to {}",
new TServerInstance(entry.getValue(), key.getColumnQualifier()));
return null;
} else if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.hasColumns(key)) {
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java
index dd4206d..06fe373 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java
@@ -623,7 +623,6 @@ public class AccumuloReplicaSystem implements ReplicaSystem {
protected Set<Integer> consumeWalPrefix(ReplicationTarget target, DataInputStream wal,
Status status) throws IOException {
- Set<Integer> tids = new HashSet<>();
LogFileKey key = new LogFileKey();
LogFileValue value = new LogFileValue();
@@ -647,7 +646,7 @@ public class AccumuloReplicaSystem implements ReplicaSystem {
}
}
- return tids;
+ return desiredTids;
}
public DataInputStream getWalStream(Path p, FSDataInputStream input) throws IOException {
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index 9b15378..a281244 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -2076,7 +2076,7 @@ public class Tablet {
PriorityQueue<Pair<FileRef,Long>> fileHeap = new PriorityQueue<>(filesToCompact.size(),
(o1, o2) -> {
- if (o1.getSecond() == o2.getSecond())
+ if (o1.getSecond().equals(o2.getSecond()))
return o1.getFirst().compareTo(o2.getFirst());
if (o1.getSecond() < o2.getSecond())
return -1;