Diff
stringlengths
10
2k
Message
stringlengths
28
159
if (!shellState.getConnector().tableOperations().exists(tableName)) throw new TableNotFoundException(null, tableName, null);
Remove this call to "exit" or ensure it is really required.
scanner.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, "NOVALUE", SortedKeyIterator.class));
Complete the task associated to this TODO comment.
// Waiting 1 second for password to propogate through Zk Thread.sleep(1000);
Define and throw a dedicated exception instead of using a generic one.
String user = cl.getOptionValue(usernameOption.getOpt(), sysUser);
1 duplicated blocks of code must be removed.
import org.apache.accumulo.core.security.thrift.Credentials; Credentials credentials = getCredentials(); connector = new ZooKeeperInstance(instance, zookeepers).getConnector(credentials.getPrincipal(), credentials.getToken()); public Credentials getCredentials() { return new Credentials(username, ByteBuffer.wrap(password.getBytes()), this.getInstance().getInstanceID());
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.io.IOException; import org.apache.accumulo.core.Constants; import org.apache.hadoop.fs.Path; import org.apache.hadoop.util.StringUtils; return Base64.decodeBase64(token.getBytes(Constants.UTF8));
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.server.security.SecurityUtil; SecurityUtil.serverLogin();
Move this constructor to comply with Java Code Conventions.
if (partitions.size() > 0) shellState.getConnector().tableOperations().addSplits(tableName, partitions); if (aggregators.size() > 0) shellState.getConnector().tableOperations().addAggregators(tableName, aggregators); String formatterClass = cl.getOptionValue(createTableOptFormatter.getOpt()); shellState.setFormatterClass(tableName, AccumuloClassLoader.loadClass(formatterClass, Formatter.class)); shellState.getConnector().tableOperations().setProperty(tableName, Property.TABLE_FORMATTER_CLASS.toString(), formatterClass); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
Scanner mscanner = new IsolatedScanner(conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)); mscanner.fetchColumnFamily(MetadataTable.BULKFILE_COLUMN_FAMILY);
Use "Long.toString" instead.
* @deprecated since 1.5
26 duplicated blocks of code must be removed.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
package org.apache.accumulo.examples.mapreduce.bulk; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.PrintStream; import org.apache.accumulo.core.util.CachedConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class GenerateTestData { public static void main(String[] args) throws IOException { int startRow = Integer.parseInt(args[0]); int numRows = Integer.parseInt(args[1]); String outputFile = args[2]; Configuration conf = CachedConfiguration.getInstance(); FileSystem fs = FileSystem.get(conf); PrintStream out = new PrintStream(new BufferedOutputStream(fs.create(new Path(outputFile)))); for(int i = 0; i < numRows; i++){ out.println(String.format("row_%08d\tvalue_%08d", i+startRow,i+startRow)); } out.close(); } }
Return empty string instead.
public class LargeRowIT extends ConfigurableMacIT {
Use "Integer.toString" instead.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@Override public void visit(State state, Properties props) throws Exception { String indexTableName = (String) state.get("indexTableName"); String dataTableName = (String) state.get("docTableName"); Random rand = (Random) state.get("rand"); String table; if (rand.nextDouble() < .5) table = indexTableName; else table = dataTableName; state.getConnector().tableOperations().flush(table, null, null, true); log.debug("Flushed " + table); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.trace.instrument.receivers; * @see trace.instrument.receivers.AsyncSpanReceiver#flush() * @see trace.instrument.receivers.AsyncSpanReceiver#sendSpans()
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.security.CredentialHelper; import org.apache.accumulo.core.security.thrift.tokens.PasswordToken; shellState.updateUser(CredentialHelper.create(user, new PasswordToken().setPassword(pass), shellState.getConnector().getInstance().getInstanceID()));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.server.security.SystemCredentials; MetadataTableUtil.getMetadataTable(SystemCredentials.get().getAsThrift()).update(m); MetadataTableUtil.getMetadataTable(SystemCredentials.get().getAsThrift()).update(m);
Move this constructor to comply with Java Code Conventions.
if (propogateDeletes) break;
Remove this call to "exit" or ensure it is really required.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ * Does not show contents from scan, only displays statistics. Beware that this work is being done client side and this was developed as a utility for * debugging. If used on large result sets it will likely fail. public class StatisticsDisplayFormatter extends DefaultFormatter { private Map<String,Long> classifications = new HashMap<String,Long>(); private Map<String,Long> columnFamilies = new HashMap<String,Long>(); private Map<String,Long> columnQualifiers = new HashMap<String,Long>(); public String next() { Iterator<Entry<Key,Value>> si = super.getScannerIterator(); private void aggregateStats(Entry<Key,Value> entry) { private String getStats() { classifications = new HashMap<String,Long>(); columnFamilies = new HashMap<String,Long>(); columnQualifiers = new HashMap<String,Long>();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private String getTableInfo() { return Tables.getPrintableTableInfoFromId(instance, table); } e.setTableInfo(getTableInfo()); e.setTableInfo(getTableInfo());
Either log or rethrow this exception.
assertArrayEquals("secret".getBytes(), args.getPassword()); assertArrayEquals("foo".getBytes(), args.getPassword());
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
"-p", ROOT_PASSWORD,
Use "Integer.toString" instead.
@Test(timeout = 4 * 60 * 1000) @Test(timeout = 4 * 60 * 1000) @Test(timeout = 4 * 60 * 1000)
Either log or rethrow this exception.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
296 duplicated blocks of code must be removed.
package org.apache.accumulo.test.randomwalk.image; import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
public static class ThriftClientHandler extends ClientServiceHandler implements TabletClientService.Iface { public ThriftClientHandler(Instance instance, TransactionWatcher watcher) {
Remove this call to "exit" or ensure it is really required.
private final List<SourceSwitchingIterator> copies;
Move this variable to comply with Java Code Conventions.
ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(),
Remove this unused private "appendProp" method.
private static final int DEFAULT_TIMEOUT = 1000; public String stringify(FileObject[] files) { StringBuilder sb = new StringBuilder(); sb.append('['); String delim = ""; for (FileObject file : files) { sb.append(delim); delim = ", "; sb.append(file.getName()); } sb.append(']'); return sb.toString(); } vfs = AccumuloVFSClassLoader.generateVfs(true); log.debug("Rebuilding dynamic classloader using files- " + stringify(files));
1 duplicated blocks of code must be removed.
import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
1 duplicated blocks of code must be removed.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @SuppressWarnings("all") public enum PartialKey implements org.apache.thrift.TEnum {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); final Options opts = new Options();
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
boolean canWrite = WalkingSecurity.get(state).canWrite(WalkingSecurity.get(state).getTabAuthInfo(), tableName); // For now, just wait a second and go again if they can write! if (!canWrite) return;
Immediately return this expression instead of assigning it to the temporary variable "res".
@Override public void setTimeOut(int timeout) {} @Override public int getTimeOut() { return Integer.MAX_VALUE; }
Remove this unused method parameter "e".
client.update(batchWriter, mutation("row1", "cf", "cq", "x")); client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
Rename this class to remove "Exception" or correct its inheritance.
return this.getClass().getSuperclass().getName();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.SystemPermission; boolean exists; boolean hasPermission; target = SecurityHelper.getTabUserName(state); exists = SecurityHelper.getTabUserExists(state); conn = SecurityHelper.getSystemConnector(state); hasPermission = SecurityHelper.getSysPerm(state, SecurityHelper.getSysUserName(state), SystemPermission.ALTER_USER); target = SecurityHelper.getSysUserName(state); exists = true; hasPermission = true; String[] possibleAuths = SecurityHelper.getAuthsArray(); SecurityHelper.setUserAuths(state, target, auths);
Either log or rethrow this exception.
package org.apache.accumulo.core.util.shell.commands; import java.io.IOException; import java.util.Arrays; import java.util.Map; import java.util.Set; import org.apache.accumulo.core.util.BadArgumentException; import org.apache.accumulo.core.util.shell.Shell; import org.apache.accumulo.core.util.shell.Token; import org.apache.accumulo.core.util.shell.Shell.Command; import org.apache.commons.cli.CommandLine; public class DebugCommand extends Command { public int execute(String fullCommand, CommandLine cl, Shell shellState) throws IOException { if (cl.getArgs().length == 1) { if (cl.getArgs()[0].equalsIgnoreCase("on")) Shell.setDebugging(true); else if (cl.getArgs()[0].equalsIgnoreCase("off")) Shell.setDebugging(false); else throw new BadArgumentException("Argument must be 'on' or 'off'", fullCommand, fullCommand.indexOf(cl.getArgs()[0])); } else if (cl.getArgs().length == 0) { shellState.getReader().printString(Shell.isDebuggingEnabled() ? "on\n" : "off\n"); } else { Shell.printException(new IllegalArgumentException("Expected 0 or 1 argument. There were " + cl.getArgs().length + ".")); printHelp(); return 1; } return 0; } @Override public String description() { return "turns debug logging on or off"; } @Override public void registerCompletion(Token root, Map<Command.CompletionSet, Set<String>> special) { Token debug_command = new Token(getName()); debug_command.addSubcommand(Arrays.asList(new String[] { "on", "off" })); root.addSubcommand(debug_command); } @Override public String usage() { return getName() + " [ on | off ]"; } @Override public int numArgs() { return Shell.NO_FIXED_ARG_LENGTH_CHECK; } }
Return empty string instead.
catch (AccumuloException ex) {}
Either log or rethrow this exception.
public TabletLocation locateTablet(Text row, boolean skipRow, boolean retry, TCredentials credentials) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { public void binMutations(List<Mutation> mutations, Map<String,TabletServerMutations> binnedMutations, List<Mutation> failures, TCredentials credentials) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { public List<Range> binRanges(List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges, TCredentials credentials) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
Reduce this switch case number of lines from 12 to at most 5, for example by extracting code into methods.
MetadataTableUtil.addTablet(extent, Constants.DEFAULT_TABLET_LOCATION, SystemCredentials.get(), tableInfo.timeType, environment.getMasterLock()); MetadataTableUtil.deleteTable(tableInfo.tableId, false, SystemCredentials.get(), environment.getMasterLock()); security.grantTablePermission(SystemCredentials.get().toThrift(env.getInstance()), tableInfo.user, tableInfo.tableId, permission); AuditedSecurityOperation.getInstance().deleteTable(SystemCredentials.get().toThrift(env.getInstance()), tableInfo.tableId);
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
if (o == null) return 0; if (o1 == null || o2 == null) return o1 == o2;
Remove this call to "exit" or ensure it is really required.
} else { status = Status.ACTIVE;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.zookeeper.data.Stat; Stat stat = new Stat(); byte[] lockData = ZooLock.getLockData(lockPath, stat); instance = new TServerInstance(client, stat.getEphemeralOwner());
1 duplicated blocks of code must be removed.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); return ("" + flushID + encodedIterators).getBytes(utf8); return ("" + flushID + encodedIterators).getBytes(utf8);
Move this variable to comply with Java Code Conventions.
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.RegExFilter}
Either log or rethrow this exception.
import org.apache.accumulo.core.security.thrift.Credential; public static boolean getBatchFromServer(Credential credentials, Text startRow, KeyExtent extent, String server, SortedMap<Key,Value> results, static boolean getBatchFromServer(Credential credentials, Key key, Key endKey, KeyExtent extent, String server, SortedMap<Key,Value> results, static boolean getBatchFromServer(Credential credentials, Range range, KeyExtent extent, String server, SortedMap<Key,Value> results, Credential credentials; public ScanState(Credential credentials, Text tableName, Authorizations authorizations, Range range, SortedSet<Column> fetchedColumns, int size, public static List<KeyValue> scan(Instance instance, Credential credentials, ScanState scanState, int timeOut, AccumuloConfiguration conf)
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public static class TabletLocations { private final List<TabletLocation> locations; private final List<KeyExtent> locationless; public TabletLocations(List<TabletLocation> locations, List<KeyExtent> locationless) { this.locations = locations; this.locationless = locationless; } public List<TabletLocation> getLocations() { return locations; } public List<KeyExtent> getLocationless() { return locationless; } }
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
@Override public String description() { return "DEPRECATED: use the command line utility instead"; } @Override public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception { shellState.getReader().printString("This command is no longer supported in the shell, please use \n"); shellState.getReader().printString(" accumulo accumulo.server.master.state.SetGoalState [NORMAL|SAFE_MODE|CLEAN_STOP]\n"); return -1; } @Override public String usage() { return "use the command line utility instead"; } @Override public int numArgs() { return 0; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ private Option verboseOption; @Override public String description() { return "specifies a file containing accumulo commands to execute"; } @Override public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception { java.util.Scanner scanner = new java.util.Scanner(new File(cl.getArgs()[0])); while (scanner.hasNextLine()) shellState.execCommand(scanner.nextLine(), true, cl.hasOption(verboseOption.getOpt())); return 0; } @Override public int numArgs() { return 1; } @Override public Options getOptions() { Options opts = new Options(); verboseOption = new Option("v", "verbose", false, "displays command prompt as commands are executed"); opts.addOption(verboseOption); return opts; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper; public void initializeSecurity(InstanceTokenWrapper itw, String rootuser) throws AccumuloSecurityException {
Immediately return this expression instead of assigning it to the temporary variable "ret".
import org.apache.accumulo.cloudtrace.instrument.Span; import org.apache.accumulo.cloudtrace.thrift.RemoteSpan;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
String test = new String("test".getBytes(), encoding);
Remove this unused private "appendProp" method.
import org.apache.accumulo.core.util.MetadataTable; Scanner metadata = connector.createScanner(MetadataTable.NAME, opts.auths); metadata.setRange(MetadataTable.KEYSPACE); metadata.fetchColumnFamily(MetadataTable.DATAFILE_COLUMN_FAMILY); writer = connector.createBatchWriter(MetadataTable.NAME, bwOpts.getBatchWriterConfig());
Use "Long.toString" instead.
import jline.console.ConsoleReader; int col3 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - COL2 - 6));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.examples.wikisearch.util;
Rename "table" which hides the field declared at line 107.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @SuppressWarnings("all") public class ScanResult implements org.apache.thrift.TBase<ScanResult, ScanResult._Fields>, java.io.Serializable, Cloneable { @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.Constants; writer = FileOperations.getInstance().openWriter(ingestArgs.outputFile + "." + Constants.MAPFILE_EXTENSION, fs, conf,
6 duplicated blocks of code must be removed.
package org.apache.accumulo.examples.wikisearch.util;
Rename "table" which hides the field declared at line 107.
private NoLabelFilter ref = new NoLabelFilter(); public NoLabelIterator deepCopy(IteratorEnvironment env) { return new NoLabelIterator(this, env); } private NoLabelIterator(NoLabelIterator other, IteratorEnvironment env) { setSource(other.getSource().deepCopy(env)); ref = other.ref; } public NoLabelIterator() {} private boolean matches(Key key, Value value) { return ref.accept(key, value); } @Override protected void consume() throws IOException { while (getSource().hasTop() && !matches(getSource().getTopKey(), getSource().getTopValue())) { getSource().next(); } @Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); ref.init(options); } @Override public IteratorOptions describeOptions() { return ref.describeOptions(); } @Override public boolean validateOptions(Map<String,String> options) { return ref.validateOptions(options); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (startRow == null && endRow == null && size < 0) { shellState.getReader().flushConsole(); String line = shellState.getReader().readLine("Merge the entire table { " + tableName + " } into one tablet (yes|no)? "); if (line == null) return 0; if (!line.equalsIgnoreCase("y") && !line.equalsIgnoreCase("yes")) return 0; }
Remove this unused private "appendProp" method.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
296 duplicated blocks of code must be removed.
package org.apache.accumulo.server.test.continuous; import java.util.Map.Entry; import java.util.Random; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.ZooKeeperInstance; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.security.Authorizations; import org.apache.hadoop.io.Text; public class ContinuousQuery { public static void main(String[] args) throws Exception { if(args.length != 8){ throw new IllegalArgumentException("usage : "+ContinuousIngest.class.getName()+" <instance name> <zookeepers> <user> <pass> <table> <min> <max> <sleep time>"); } String instanceName = args[0]; String zooKeepers = args[1]; String user = args[2]; String password = args[3]; String table = args[4]; long min = Long.parseLong(args[5]); long max = Long.parseLong(args[6]); long sleepTime = Long.parseLong(args[7]); Connector conn = new ZooKeeperInstance(instanceName, zooKeepers).getConnector(user, password.getBytes()); Scanner scanner = conn.createScanner(table, new Authorizations()); Random r = new Random(); while(true){ byte[] row = ContinuousIngest.genRow(min, max, r); int count = 0; long t1 = System.currentTimeMillis(); scanner.setRange(new Range(new Text(row))); for (Entry<Key, Value> entry : scanner) { ContinuousWalk.validate(entry.getKey(), entry.getValue()); count++; } long t2 = System.currentTimeMillis(); System.out.printf("SRQ %d %s %d %d\n",t1, new String(row), (t2 - t1), count); if(sleepTime > 0) Thread.sleep(sleepTime); } } }
Return empty string instead.
package org.apache.accumulo.examples.wikisearch.normalizer; import org.apache.accumulo.examples.wikisearch.normalizer.NumberNormalizer;
2 duplicated blocks of code must be removed.
public MajorCompactor(AccumuloConfiguration config) { CompactionWatcher.startWatching(config); } majorCompactorThread = new Daemon(new LoggingRunnable(log, new MajorCompactor(getSystemConfiguration())));
1 duplicated blocks of code must be removed.
import org.apache.accumulo.core.Constants; assertEquals(" i#maxWriteThreads=42", new String(bytes, Constants.UTF8)); assertEquals(" v#maxWriteThreads=24,timeout=3000", new String(bytes, Constants.UTF8));
Move this variable to comply with Java Code Conventions.
@SuppressWarnings("all") public class MasterClientService {
13 duplicated blocks of code must be removed.
port, TCompactProtocol.Factory.class, prop);
This block of commented-out lines of code should be removed.
if (fs.exists(mylog)) break;
Remove this call to "exit" or ensure it is really required.
exec("offline -w ptc"); exec("online -w ptc");
Cast one of the operands of this multiplication operation to a "long".
import java.util.TreeMap;
2 duplicated blocks of code must be removed.
getZooCache(instance).clear(ZooUtil.getRoot(instance) + Constants.ZTABLES);
Do not forget to remove this deprecated code someday.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
Move this constructor to comply with Java Code Conventions.
SimpleTimer.getInstance().schedule(new Runnable() {
Return empty string instead.
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; clazz = AccumuloVFSClassLoader.loadClass(className, OptionDescriber.class);
Remove this unused private "appendProp" method.
import org.apache.accumulo.core.security.thrift.Credentials; Credentials auth; auth = WalkingSecurity.get(state).getSysCredentials(); auth = state.getCredentials();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private Class<? extends Formatter> defaultFormatterClass = DefaultFormatter.class; private Map<String, Class<? extends Formatter>> tableFormatters = new HashMap<String, Class<? extends Formatter>>(); if (!tableFormatters.isEmpty()) { sb.append("- Active Formatters"); for (Entry<String, Class<? extends Formatter>> entry : tableFormatters.entrySet()) { if (null != entry.getValue()) { sb.append("- Table: ").append(entry.getKey()).append(", ").append(entry.getValue().getName()).append("\n"); } } Class<? extends Formatter> formatterClass = getFormatterClass(this.tableName); public void setFormatterClass(String tableName, Class<? extends Formatter> formatter) { this.tableFormatters.put(tableName, formatter); /** * Pull the current formatter for the given table and cache it. * @param tableName * @return The formatter class for the given table */ public Class<? extends Formatter> getFormatterClass(String tableName) { if (this.tableFormatters.containsKey(tableName) && null != this.tableFormatters.get(tableName)) { return this.tableFormatters.get(tableName); } else { Class<? extends Formatter> formatter = FormatterCommand.getCurrentFormatter(tableName, this); if (null == formatter) { return this.defaultFormatterClass; } else { return formatter; } }
Remove this unused private "debugQuery" method.
@Override public int execute(String fullCommand, CommandLine cl, Shell shellState) { shellState.setExit(true); return 0; } @Override public String description() { return "exits the shell"; } @Override public int numArgs() { return 0; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
// if dir exist and is empty, then empty list is returned... // hadoop 1.0 will return null if the file doesn't exist // hadoop 2.0 will throw an exception if the file does not exist FileStatus[] tabletDirs = null; try { tabletDirs = fs.listStatus(new Path(ServerConstants.getTablesDir() + "/" + delTableId)); } catch (FileNotFoundException ex) { // ignored }
Either log or rethrow this exception.
/** * indicates a variable-length encoding of a list of Longs using {@link SummingArrayCombiner.VarLongArrayEncoder} */ VARLEN, /** * indicates a fixed-length (8 bytes for each Long) encoding of a list of Longs using {@link SummingArrayCombiner.FixedLongArrayEncoder} */ FIXEDLEN, /** * indicates a string (comma-separated) representation of a list of Longs using {@link SummingArrayCombiner.StringArrayEncoder} */ STRING
Either log or rethrow this exception.
package org.apache.accumulo.server.test.randomwalk.shard; import java.util.Map.Entry; import java.util.Properties; import java.util.Random; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.server.test.randomwalk.State; import org.apache.accumulo.server.test.randomwalk.Test; public class Delete extends Test { @Override public void visit(State state, Properties props) throws Exception { String indexTableName = (String)state.get("indexTableName"); String dataTableName = (String)state.get("docTableName"); int numPartitions = (Integer)state.get("numPartitions"); Random rand = (Random) state.get("rand"); Entry<Key, Value> entry = Search.findRandomDocument(state, dataTableName, rand); if(entry == null) return; String docID = entry.getKey().getRow().toString(); String doc = entry.getValue().toString(); Insert.unindexDocument(state.getMultiTableBatchWriter().getBatchWriter(indexTableName), doc, docID, numPartitions); Mutation m = new Mutation(docID); m.putDelete("doc", ""); state.getMultiTableBatchWriter().getBatchWriter(dataTableName).addMutation(m); log.debug("Deleted document "+docID); state.getMultiTableBatchWriter().flush(); } }
Return empty string instead.
import org.apache.accumulo.server.zookeeper.IZooReaderWriter; final IZooReaderWriter new_ = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), newPass); IZooReaderWriter orig = new ZooReaderWriter(origInstance.getZooKeepers(), origInstance.getZooKeepersSessionTimeOut(), oldPass);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
assertEquals(base + 3, countFiles()); assertEquals(base + 2, countFiles());
Replace this if-then-else statement by a single return statement.
public static final String METADATA_DELETE_FLAG_FOR_METADATA_PREFIX = "!!" + METADATA_DELETE_FLAG_PREFIX; public static final Range METADATA_DELETES_FOR_METADATA_KEYSPACE = new Range(new Key(new Text(METADATA_DELETE_FLAG_FOR_METADATA_PREFIX)), true, new Key(new Text("!!~dem")), false);
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.core.client.MultiTableBatchWriter; public void testMockMultiTableBatchWriter() throws Exception { Connector c = new MockConnector("root"); c.tableOperations().create("a"); c.tableOperations().create("b"); MultiTableBatchWriter bw = c.createMultiTableBatchWriter(10000L, 1000L, 4); Mutation m1 = new Mutation("r1"); m1.put("cf1", "cq1", 1, "v1"); BatchWriter b = bw.getBatchWriter("a"); b.addMutation(m1); b.flush(); b = bw.getBatchWriter("b"); b.addMutation(m1); b.flush(); Scanner scanner = c.createScanner("a", Constants.NO_AUTHS); int count = 0; for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) { count++; } assertEquals(1, count); scanner = c.createScanner("b", Constants.NO_AUTHS); for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) { count++; } assertEquals(1, count); }
Define and throw a dedicated exception instead of using a generic one.
package org.apache.accumulo.core.file.blockfile.cache; public class SizeConstants { public static final int SIZEOF_BOOLEAN = Byte.SIZE/Byte.SIZE; /** * Size of byte in bytes */ public static final int SIZEOF_BYTE = SIZEOF_BOOLEAN; /** * Size of char in bytes */ public static final int SIZEOF_CHAR = Character.SIZE/Byte.SIZE; /** * Size of double in bytes */ public static final int SIZEOF_DOUBLE = Double.SIZE/Byte.SIZE; /** * Size of float in bytes */ public static final int SIZEOF_FLOAT = Float.SIZE/Byte.SIZE; /** * Size of int in bytes */ public static final int SIZEOF_INT = Integer.SIZE/Byte.SIZE; /** * Size of long in bytes */ public static final int SIZEOF_LONG = Long.SIZE/Byte.SIZE; /** * Size of short in bytes */ public static final int SIZEOF_SHORT = Short.SIZE/Byte.SIZE; }
Return empty string instead.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.server.tabletserver; import static org.junit.Assert.*; import org.junit.Test; public class SimpleLRUCacheTest { @Test public void test() { SimpleLRUCache<Integer> test = new SimpleLRUCache<Integer>(4); test.add(0); assertTrue(test.contains(0)); test.add(1); assertTrue(test.contains(1)); assertFalse(test.contains(2)); test.add(2); test.add(3); test.add(4); assertFalse(test.contains(0)); test.add(2); test.add(2); test.add(2); test.add(2); assertTrue(test.contains(3)); assertTrue(test.contains(4)); } }
Return empty string instead.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
* <li>{@link AccumuloRowInputFormat#setConnectorInfo(JobConf, String, AuthenticationToken)}
3 duplicated blocks of code must be removed.
/** * Provides a GUI for browsing the file system information stored in Accumulo. See docs/examples/README.dirlist for instructions. */
Replace this use of System.out or System.err by a logger.
* @since 1.5.0 * @since 1.5.0 * @since 1.5.0
Move this constructor to comply with Java Code Conventions.
"The ScanInterpreter class to apply on scan arguments in the shell"), //VFS ClassLoader properties VFS_CLASSLOADER_PREFIX("classloader.vfs", null, PropertyType.PREFIX, "Properties in this category affect the VFS ClassLoader"), VFS_CLASSLOADER_ENABLED("classloader.vfs.enabled", "false", PropertyType.BOOLEAN, "Enable/disable VFS Classloader"), VFS_CLASSLOADER_SYSTEM_CLASSPATH_PROPERTY("classloader.vfs.context.classpath.system", "", PropertyType.STRING, "Classpath for the system context"), VFS_CLASSLOADER_CONTEXT_NAMES_PROPERTY("classloader.vfs.context.names", "", PropertyType.STRING, "Comma separated list of context names"), VFS_CONTEXT_CLASSPATH_PROPERTY("classloader.vfs.context.classpath.", null, PropertyType.PREFIX, "Classpath for this context");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (maxOpen <= 0) throw new IllegalArgumentException("maxOpen <= 0"); if (!sawIOException) getFileList(fileName, openFiles).add(new OpenReader(fileName, reader)); if (sawIOException) closeReaders(readers); if (tabletReservedReaders.size() != 0) throw new IllegalStateException();
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.core.client.BatchWriterConfig; BatchWriter bw = getConnector().createBatchWriter("foo", new BatchWriterConfig());
Remove this unused method parameter "e".
package org.apache.accumulo.trace.instrument.receivers; import org.apache.accumulo.trace.thrift.RemoteSpan; import org.apache.accumulo.trace.thrift.SpanReceiver.Client;
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.server.security.SecurityOperationImpl; private static SecurityOperation security = SecurityOperationImpl.getInstance();
Either log or rethrow this exception.
import org.apache.accumulo.core.security.thrift.ThriftSecurityException; import org.apache.accumulo.core.security.tokens.AuthenticationToken; import org.apache.accumulo.core.security.tokens.PasswordToken;
1 duplicated blocks of code must be removed.