Diff
stringlengths
10
2k
Message
stringlengths
28
159
* A utility function that checks that each tablet has an expected number of rfiles. protected void checkRFiles(String tableName, int minTablets, int maxTablets, int minRFiles, int maxRFiles) throws Exception { if (entry.getValue() > maxRFiles || entry.getValue() < minRFiles) {
Either log or rethrow this exception.
import junit.framework.TestCase;
2 duplicated blocks of code must be removed.
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.fs.VolumeManagerImpl; import org.junit.rules.TemporaryFolder; VolumeManager fs; TemporaryFolder root = new TemporaryFolder(); fs = VolumeManagerImpl.getLocal(); root.create(); String path = root.getRoot().getAbsolutePath(); Path root = new Path("file://" + path + "/manyMaps"); FileSystem ns = fs.getDefaultVolume(); Writer writer = new Writer(ns.getConf(), ns, new Path(root, "odd").toString(), IntWritable.class, BytesWritable.class); writer = new Writer(ns.getConf(), ns, new Path(root, "even").toString(), IntWritable.class, BytesWritable.class); root.create(); Path manyMaps = new Path("file://" + root.getRoot().getAbsolutePath() + "/manyMaps"); MultiReader reader = new MultiReader(fs, manyMaps); fs.deleteRecursively(new Path(manyMaps, "even")); reader = new MultiReader(fs, manyMaps);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
// single command to execute from the command line private String execCommand = null; Option execCommandOpt = new Option("e", "execute-command", true, "executes a command, and then exits"); opts.addOption(execCommandOpt); } else if (cl.hasOption(execfileVerboseOption.getOpt())) { } if (cl.hasOption(execCommandOpt.getOpt())) { execCommand = cl.getOptionValue(execCommandOpt.getOpt()); } } else if (execCommand != null) { for (String command : execCommand.split("\n")) { execCommand(command, true, isVerbose()); } return exitCode;
Remove this unused private "Reader" constructor.
@Deprecated
Remove this unused method parameter "ex".
import org.apache.accumulo.core.security.thrift.TCredentials; private TCredentials credentials; ScannerIterator(Instance instance, TCredentials credentials, Text table, Authorizations authorizations, Range range, int size, int timeOut,
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. */
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. */
Replace all tab characters in this file by sequences of white-spaces.
// This does not use ACCUMULO_CONF_DIR since it is used to get to the conf/examples dirs
2 duplicated blocks of code must be removed.
package org.apache.accumulo.examples.wikisearch.iterator;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
for (String opt : options.keySet()) { try { if (options.equals(AUTH_OPT)) { new Authorizations(options.get(opt).getBytes()); } else if (opt.equals(MAX_BUFFER_SIZE_OPT)) { AccumuloConfiguration.getMemoryInBytes(options.get(opt)); } } catch (Exception e) { throw new IllegalArgumentException("Failed to parse opt " + opt + " " + options.get(opt), e); } }
Either log or rethrow this exception.
switch (ae.getSecurityErrorCode()) {
Do not forget to remove this deprecated code someday.
return new Value(Long.toString(min).getBytes());
Remove this unused method parameter "ex".
if (!hasNext()) throw new NoSuchElementException(); if (count == 0) throw new TabletDeletedException("Tablet " + lastTablet + " was deleted while iterating");
Remove this call to "exit" or ensure it is really required.
state, ss.extent.toThrift(), Translator.translate(ss.columnSet, Translator.CT), ss.ssiList, ss.ssio, ss.auths.getAuthorizationsBB())); ScanType.BATCH, state, mss.threadPoolExtent.toThrift(), Translator.translate(mss.columnSet, Translator.CT), mss.ssiList, mss.ssio, mss.auths.getAuthorizationsBB())); public Authorizations auths; scanSession.auths = new Authorizations(authorizations); scanSession.scanner = tablet.createScanner(new Range(range), batchSize, scanSession.columnSet, scanSession.auths, ssiList, ssio,
Replace all tab characters in this file by sequences of white-spaces.
printConfLine(output, "site", printed ? " @override" : key, siteVal == null ? "" : siteVal); printConfLine(output, "system", printed ? " @override" : key, sysVal == null ? "" : sysVal);
Define a constant instead of duplicating this literal " @override" 3 times.
package org.apache.accumulo.server.monitor.util.celltypes; import org.apache.accumulo.core.master.thrift.Compacting; import org.apache.accumulo.core.master.thrift.TableInfo; public class CompactionsType extends CellType<TableInfo> { private String fieldName; public CompactionsType(String which) { this.fieldName = which; } @Override public String format(Object obj) { if (obj == null) return "-"; TableInfo summary = (TableInfo) obj; Compacting c = summary.major; if (fieldName.equals("minor")) c = summary.minor; else if(fieldName.equals("scans")) c = summary.scans; if (c == null) c = new Compacting(); return String.format("%s&nbsp;(%,d)", NumberType.commas(c.running, c.queued == 0 ? 0 : 1, summary.onlineTablets), c.queued); } @Override public int compare(TableInfo o1, TableInfo o2) { if (o1 == null) return -1; if (o2 == null) return 1; Compacting c1 = o1.major; Compacting c2 = o2.major; if (fieldName.equals("minor")) { c1 = o1.minor; c2 = o2.minor; }else if(fieldName.equals("scans")){ c1 = o1.scans; c2 = o2.scans; } if (c1 == null) return -1; if (c2 == null) return 1; return c1.running + c1.queued - c2.running - c2.queued; } @Override public String alignment() { return "right"; } }
Return empty string instead.
import org.apache.accumulo.core.security.tokens.UserPassToken; private static final UserPassToken TEST_TOKEN = new UserPassToken(TEST_USER, TEST_PASS); getConnector().securityOperations().createUser(TEST_TOKEN); test_user_conn.securityOperations().createUser(TEST_TOKEN); root_conn.securityOperations().createUser(TEST_TOKEN); root_conn.securityOperations().createUser(TEST_TOKEN); test_user_conn.securityOperations().createUser(TEST_TOKEN); root_conn.securityOperations().createUser(TEST_TOKEN); root_conn.securityOperations().createUser(TEST_TOKEN); getConnector().securityOperations().createUser(TEST_TOKEN);
Immediately return this expression instead of assigning it to the temporary variable "ret".
final byte[] inputBytes = input.getBytes();
Remove this unused method parameter "ex".
package org.apache.accumulo.examples.simple.combiner;
Rename "table" which hides the field declared at line 107.
* Sets the connector information needed to communicate with Accumulo in this job. * * <p> * Stores the password in a file in HDFS and pulls that into the Distributed Cache in an attempt to be more secure than storing it in the Configuration. * * @param job * the Hadoop job instance to be configured * @param principal * a valid Accumulo user name (user must have Table.CREATE permission) * @param tokenFile * the path to the token file * @throws AccumuloSecurityException * @since 1.6.0 */ public static void setConnectorInfo(JobConf job, String principal, String tokenFile) throws AccumuloSecurityException { InputConfigurator.setConnectorInfo(CLASS, job, principal, tokenFile); } /** * Gets the password file from the configuration. It is BASE64 encoded to provide a charset safe conversion to a string, and is not intended to be secure. If * specified, the password will be stored in a file rather than in the Configuration. * * @param job * the Hadoop context for the configured job * @return path to the password file as a String * @since 1.6.0 * @see #setConnectorInfo(JobConf, String, AuthenticationToken) */ protected static String getTokenFile(JobConf job) { return InputConfigurator.getTokenFile(CLASS, job); } /**
Either log or rethrow this exception.
public final static long CONFIG_FILE_RELOAD_DELAY = 60000;
Make this member "protected".
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); zk.putPersistentData(getTXPath(tid), TStatus.NEW.name().getBytes(utf8), NodeExistsPolicy.FAIL); zk.putPersistentData(getTXPath(tid), status.name().getBytes(utf8), NodeExistsPolicy.OVERWRITE); zk.putPersistentData(getTXPath(tid) + "/prop_" + prop, ("S " + so).getBytes(utf8), NodeExistsPolicy.OVERWRITE);
Move this variable to comply with Java Code Conventions.
fail("checkIteratorConflicts did not throw an exception");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
return Base64.decodeBase64(node.getBytes());
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. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.security.tokens.AccumuloToken; public void createUser(AccumuloToken<?,?> token) throws AccumuloException, AccumuloSecurityException; * @deprecated @since 1.5, use {@link #changeUserPassword(AccumuloToken)} * Set the user's password * * @param user * the name of the user to modify * @param password * the plaintext password for the user * @throws AccumuloException * if a general error occurs * @throws AccumuloSecurityException * if the user does not have permission to modify a user */ public void changeUserPassword(AccumuloToken<?,?> newToken) throws AccumuloException, AccumuloSecurityException; /** /** * @deprecated @since 1.5, use {@link #createUser(AccumuloToken)} * @param token * @param authorization * @throws AccumuloException * @throws AccumuloSecurityException */ void createUser(AccumuloToken<?,?> token, Authorizations authorization) throws AccumuloException, AccumuloSecurityException;
Immediately return this expression instead of assigning it to the temporary variable "ret".
* 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. */ public abstract class SystemConstraint implements Constraint {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.start.classloader.AccumuloClassLoader; String principal = conf.get(Property.TRACE_USER); Map<String,String> loginMap = conf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX); int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length() + 1; AuthenticationToken token; try { token = AccumuloClassLoader.getClassLoader().loadClass(conf.get(Property.TRACE_TOKEN_TYPE)).asSubclass(AuthenticationToken.class).newInstance(); } catch (Exception e) { throw new AccumuloException(e); } token.init(props); at = token;
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
package org.apache.accumulo.test.randomwalk.concurrent; import org.apache.accumulo.test.randomwalk.Fixture; import org.apache.accumulo.test.randomwalk.State;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
* 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. */ DefaultMap<String,String> map = new DefaultMap<String,String>("");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
final AtomicBoolean stop; public Closer(ThriftTransportPool pool, AtomicBoolean stop) { this.stop = stop; while (!stop.get()) { private static AtomicBoolean stopDaemon; stopDaemon = new AtomicBoolean(false); new Daemon(new Closer(instance, stopDaemon), "Thrift Connection Pool Checker").start(); public static void close() { if (daemonStarted.compareAndSet(true, false)) { stopDaemon.set(true); } }
Move this variable to comply with Java Code Conventions.
* 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. */ public TabletStatusMessage(TabletLoadState status, KeyExtent extent) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
AccumuloOutputFormat.setOutputInfo(job.getConfiguration(), args[0], args[1].getBytes(), true, args[5]); AccumuloOutputFormat.setZooKeeperInstance(job.getConfiguration(), args[3], args[4]);
This block of commented-out lines of code should be removed.
private static final long serialVersionUID = 1L; private static final LoggerStatus NO_STATUS = new LoggerStatus(); @Override protected String getTitle(HttpServletRequest req) { return "Logger Server Status"; } private void doDeadLoggerList(HttpServletRequest req, StringBuilder sb) { MasterMonitorInfo mmi = Monitor.getMmi(); if (mmi != null) { List<DeadServer> obit = mmi.deadLoggers; Table deadTServerList = new Table("deadLoggers", "Dead&nbsp;Loggers", "error"); deadTServerList.setSubCaption("The following loggers are no longer reachable."); TServersServlet.doDeadServerTable(req, sb, deadTServerList, obit); } @Override protected void pageBody(HttpServletRequest req, HttpServletResponse response, StringBuilder sb) throws Exception { String loggerAddress = req.getParameter("s"); doDeadLoggerList(req, sb); if (loggerAddress == null || loggerAddress.isEmpty()) { ArrayList<LoggerStatus> loggers = new ArrayList<LoggerStatus>(); if (Monitor.getMmi() != null) loggers.addAll(Monitor.getMmi().loggers); Table loggerList = new Table("loggers", "Logger&nbsp;Servers"); doLoggerServerList(req, sb, loggers, loggerList); return; } static void doLoggerServerList(HttpServletRequest req, StringBuilder sb, List<LoggerStatus> loggers, Table loggerList) { loggerList.addSortableColumn("Server", new LoggerLinkType(), null); for (LoggerStatus status : loggers) { if (status == null) status = NO_STATUS; RecoveryStatus s = new RecoveryStatus(); s.host = status.logger; loggerList.addRow(s); loggerList.generate(req, sb); }
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. */
Replace all tab characters in this file by sequences of white-spaces.
return ("" + flushID + encodedIterators).getBytes(); return ("" + flushID + encodedIterators).getBytes();
Remove this unused method parameter "ex".
static List<String> parts(Object... parts) { List<String> result = new ArrayList<String>(); for (Object obj : parts) { result.add(obj.toString()); return result; } @Test public void testJoin() { assertEquals(StringUtil.join(parts(), ","), ""); assertEquals(StringUtil.join(parts("a", "b", "c"), ","), "a,b,c"); assertEquals(StringUtil.join(parts("a"), ","), "a"); assertEquals(StringUtil.join(parts("a", "a"), ","), "a,a"); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.server.util; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; public class NamingThreadFactory implements ThreadFactory { private ThreadFactory dtf = Executors.defaultThreadFactory(); private int threadNum = 1; private String name; public NamingThreadFactory(String name){ this.name = name; } public Thread newThread(Runnable r) { Thread thread = dtf.newThread(r); thread.setName(name+" "+threadNum++); return thread; } }
Return empty string instead.
@Override public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {}
Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-z0-9]*)*$'.
Compacting c = summary.majors; c = summary.minors; Compacting c1 = o1.majors; Compacting c2 = o2.majors; c1 = o1.minors; c2 = o2.minors;
Refactor the code to remove this label and the need for it.
if (!topKey.getColumnFamilyData().equals(FileDataIngest.CHUNK_CF_BS)) return topKey.getColumnVisibility().getBytes(); if (source.getTopKey().getTimestamp() > maxTS) maxTS = source.getTopKey().getTimestamp(); if (!topValue.equals(source.getTopValue())) throw new RuntimeException("values not equals " + topKey + " " + source.getTopKey() + " : " + diffInfo(topValue, source.getTopValue())); if (lastRowVC.containsKey(row)) return lastRowVC.get(row); if (vc == null) vc = new VisibilityCombiner();
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. */
Remove this unused private "appendProp" method.
import org.apache.accumulo.core.metadata.schema.DataFileValue;
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. */ Iterator<E> source; E top; public PeekingIterator(Iterator<E> source) { this.source = source; if (source.hasNext()) top = source.next(); else top = null; } public E peek() { return top; } public E next() { E lastPeeked = top; if (source.hasNext()) top = source.next(); else top = null; return lastPeeked; } public void remove() { throw new UnsupportedOperationException(); } @Override public boolean hasNext() { return top != null; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
try { // watcher only fires once, add it back ZooReaderWriter.getInstance().getChildren(zroot + Constants.ZRECOVERY, this); } catch (Exception e) { log.error("Failed to add log recovery watcher back", e); }
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
* 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. */ @Override public Long typedReduce(Key key, Iterator<Long> iter) { long min = Long.MAX_VALUE; while (iter.hasNext()) { Long l = iter.next(); if (l < min) min = l; } return min; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* An Accumulo Shell implementation that allows a developer to attach an InputStream and Writer to the Shell for testing purposes. public boolean config(String... args) { configError = super.config(args); } catch (Exception e) { return configError; if (hasExited()) * @param in * the in to set * @param writer * the writer to set * * @param commands
Either log or rethrow this exception.
package org.apache.accumulo.test.randomwalk.shard; 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.
/** * This class remains here for backwards compatibility. * * @deprecated since 1.4 * @see org.apache.accumulo.core.iterators.user.VersioningIterator */ public class VersioningIterator extends org.apache.accumulo.core.iterators.user.VersioningIterator { super(iterator, maxVersions);
Remove this unused private "match" method.
import org.apache.accumulo.core.security.Authorizations; Scanner mdScanner = new ScannerImpl(HdfsZooInstance.getInstance(), credentials, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); ScannerImpl scanner2 = new ScannerImpl(HdfsZooInstance.getInstance(), credentials, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); Scanner scanner3 = new ScannerImpl(HdfsZooInstance.getInstance(), credentials, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); Scanner ms = new ScannerImpl(HdfsZooInstance.getInstance(), credentials, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); Scanner scanner = new ScannerImpl(HdfsZooInstance.getInstance(), credentials, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); // there's a little race between getting the children and fetching // the data. The log can be removed in between. Scanner scanner = new ScannerImpl(HdfsZooInstance.getInstance(), credentials, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); .createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY); Scanner mscanner = new IsolatedScanner(conn.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY)); Scanner mscanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY); Scanner mscanner = new IsolatedScanner(conn.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY)); Scanner mscanner = new IsolatedScanner(conn.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY)); Scanner scanner = new ScannerImpl(HdfsZooInstance.getInstance(), credentials, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); Scanner scanner = new ScannerImpl(instance, creds, Constants.METADATA_TABLE_ID, Authorizations.EMPTY); m.put(new byte[] {}, new byte[] {}, new byte[] {}); m.putDelete(new byte[] {}, new byte[] {});
Remove this unused method parameter "range".
Connector c = getInstance(implementingClass, conf).getConnector(getPrincipal(implementingClass, conf), CredentialHelper.extractToken(getTokenClass(implementingClass, conf), getToken(implementingClass, conf)));
Immediately return this expression instead of assigning it to the temporary variable "connector".
import org.apache.accumulo.cloudtrace.instrument.Span; import org.apache.accumulo.cloudtrace.instrument.Trace; import org.apache.accumulo.cloudtrace.instrument.thrift.TraceWrap; import org.apache.accumulo.cloudtrace.thrift.TInfo;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public final static String PARTITIONED_ARTICLES_DIRECTORY = "wikipedia.partitioned.directory"; public final static String RUN_PARTITIONER = "wikipedia.run.partitioner"; public final static String RUN_INGEST = "wikipedia.run.ingest"; public static Path getPartitionedArticlesPath(Configuration conf) { return new Path(conf.get(PARTITIONED_ARTICLES_DIRECTORY)); } public static boolean runPartitioner(Configuration conf) { return conf.getBoolean(RUN_PARTITIONER, false); } public static boolean runIngest(Configuration conf) { return conf.getBoolean(RUN_INGEST, true); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private static final Logger log = Logger.getLogger(EventCoordinator.class); long eventCounter = 0; synchronized long waitForEvents(long millis, long lastEvent) { // Did something happen since the last time we waited? if (lastEvent == eventCounter) { // no if (millis <= 0) return eventCounter; try { wait(millis); } catch (InterruptedException e) { log.debug("ignoring InterruptedException", e); } return eventCounter; } synchronized public void event(String msg, Object... args) { log.info(String.format(msg, args)); eventCounter++; notifyAll(); } public Listener getListener() { return new Listener(); } public class Listener { long lastEvent; Listener() { lastEvent = eventCounter; public void waitForEvents(long millis) { lastEvent = EventCoordinator.this.waitForEvents(millis, lastEvent); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.test.randomwalk.concurrent; 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.
import org.apache.accumulo.server.cli.ClientOpts; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.fs.VolumeManagerImpl; VolumeManager fs = VolumeManagerImpl.get(); Path map = fs.getFullPath(key);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.server.thrift.metrics; public interface ThriftMetricsMBean { public static final String idle = "idle"; public static final String execute = "execute"; public long getIdleCount(); public long getIdleMinTime(); public long getIdleMaxTime(); public long getIdleAvgTime(); public long getExecutionCount(); public long getExecutionMinTime(); public long getExecutionMaxTime(); public long getExecutionAvgTime(); public void reset(); }
Return empty string instead.
* Autogenerated by Thrift Compiler (0.9.0) import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; private byte __isset_bitfield = 0; __isset_bitfield = other.__isset_bitfield; __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PARTNEXTKEYINCLUSIVE_ISSET_ID); return EncodingUtils.testBit(__isset_bitfield, __PARTNEXTKEYINCLUSIVE_ISSET_ID); __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PARTNEXTKEYINCLUSIVE_ISSET_ID, value); __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __MORE_ISSET_ID); return EncodingUtils.testBit(__isset_bitfield, __MORE_ISSET_ID); __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MORE_ISSET_ID, value); // check for sub-struct validity if (partScan != null) { partScan.validate(); } if (partNextKey != null) { partNextKey.validate(); } __isset_bitfield = 0;
Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.
public File getAccumuloDir() {
Remove this empty statement.
iter.init(source, is.getOptions(), env); iter.init(source, is.getOptions(), env); iter.init(mi, is.getOptions(), env); iter.init(source, is.getOptions(), env);
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
import org.apache.accumulo.test.functional.SimpleMacIT; public class BatchWriterIT extends SimpleMacIT { @Test(timeout = 30 * 1000) String table = getTableNames(1)[0]; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (destination == null) return null; if (client != null) { try { client.span(s); } catch (Exception ex) { client.getInputProtocol().getTransport().close(); client = null; } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
shell.config("--fake", "-p", "");
1 duplicated blocks of code must be removed.
import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ChoppedColumnFamily; prevRow.put(TabletsSection.CurrentLocationColumnFamily.NAME, new Text("123456"), new Value("127.0.0.1:1234".getBytes())); ChoppedColumnFamily.CHOPPED_COLUMN.put(prevRow, new Value("junk".getBytes())); defaultTablet.put(TabletsSection.CurrentLocationColumnFamily.NAME, new Text("123456"), new Value("127.0.0.1:1234".getBytes())); TabletsSection.TabletColumnFamily.SPLIT_RATIO_COLUMN.put(m, new Value("0.5".getBytes())); TabletsSection.TabletColumnFamily.OLD_PREV_ROW_COLUMN.put(m, KeyExtent.encodePrevEndRow(new Text("o"))); deleter.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME); TabletsSection.TabletColumnFamily.SPLIT_RATIO_COLUMN.put(m, new Value("0.5".getBytes())); ChoppedColumnFamily.CHOPPED_COLUMN.put(m, new Value("junk".getBytes()));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
AccumuloOutputFormat.setZooKeeperInstance(conf, args[0], args[1]); AccumuloOutputFormat.setOutputInfo(conf, args[3], args[4].getBytes(), true, null);
This block of commented-out lines of code should be removed.
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.nio.ByteBuffer; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.TreeMap; import org.apache.accumulo.proxy.thrift.AccumuloException; import org.apache.accumulo.proxy.thrift.AccumuloSecurityException; import org.apache.accumulo.proxy.thrift.SystemPermission; import org.apache.accumulo.proxy.thrift.TableNotFoundException; import org.apache.accumulo.proxy.thrift.TablePermission; import org.apache.accumulo.proxy.thrift.TimeType; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; prop.setProperty("useMockInstance", "true");
Either log or rethrow this exception.
import org.apache.accumulo.core.security.CredentialHelper; client.update(Tracer.traceInfo(), CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), new KeyExtent(new Text("!!"), null, new Text("row_0003750000")).toThrift(), mutation.toThrift());
Immediately return this expression instead of assigning it to the temporary variable "connector".
/* * 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 java.util.ListIterator; import jline.console.history.History.Entry; import jline.console.history.History; import jline.console.history.PersistentHistory; shellState.getReader().getHistory().clear(); ListIterator<Entry> it = shellState.getReader().getHistory().entries(); shellState.printLines(new HistoryLineIterator(it), !cl.hasOption(disablePaginationOpt.getOpt())); * Decorator that converts an Iterator<History.Entry> to an Iterator<String>. public HistoryLineIterator(Iterator<Entry> iterator) { public String next() { return super.next().toString();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* http://www.apache.org/licenses/LICENSE-2.0 /** * Creates FileContentInfo instances for HDFS. * * @since 2.1 */ public class HdfsFileContentInfoFactory implements FileContentInfoFactory { private static final String CONTENT = "text/plain"; private static final String ENCODING = "UTF-8"; /** * Creates a FileContentInfo for a the given FileContent. * * @param fileContent * Use this FileContent to create a matching FileContentInfo * @return a FileContentInfo for the given FileContent with content set to "text/plain" and encoding set to "UTF-8" * @throws FileSystemException * when a problem occurs creating the FileContentInfo. */ @Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { return new DefaultFileContentInfo(CONTENT, ENCODING); }
Either log or rethrow this exception.
import org.apache.accumulo.trace.instrument.CountSampler; import org.apache.accumulo.trace.instrument.Trace; return ((r.nextLong() & 0x7fffffffffffffffl) % (max - min)) + min;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
}, false, null);
Complete the task associated to this TODO comment.
import org.apache.accumulo.server.mini.MiniAccumuloCluster; import org.apache.accumulo.server.mini.MiniAccumuloConfig;
This block of commented-out lines of code should be removed.
this.seek(fake, null, false);
4 duplicated blocks of code must be removed.
TIteratorSetting _elem100; // required TIteratorSetting _elem105; // required
Remove this unused method parameter "table".
package org.apache.accumulo.examples.wikisearch.sample;
Rename "table" which hides the field declared at line 107.
* an array of {@link BatchScanConfig} objects to associate with the job * Returns all {@link BatchScanConfig} objects associated with this job. * Returns the {@link BatchScanConfig} for the given table public static BatchScanConfig getBatchScanConfig(Class<?> implementingClass, Configuration conf, String tableName) {
Do not forget to remove this deprecated code someday.
import org.apache.accumulo.core.client.impl.TabletLocator.TabletLocations; import org.apache.accumulo.core.util.Pair; public TabletLocations lookupTablet(TabletLocation src, Text row, Text stopRow, TabletLocator parent) throws AccumuloSecurityException, ArrayList<TabletLocation> list = new ArrayList<TabletLocation>(); Pair<SortedMap<KeyExtent,Text>,List<KeyExtent>> metadata = MetadataTable.getMetadataLocationEntries(results); for (Entry<KeyExtent,Text> entry : metadata.getFirst().entrySet()) { return new TabletLocations(list, metadata.getSecond()); return null; SortedMap<KeyExtent,Text> metadata = MetadataTable.getMetadataLocationEntries(results).getFirst();
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
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. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.server.security.SystemCredentials; public void visit(State state, Properties props) throws Exception { SetGoalState.main(new String[] {MasterGoalState.CLEAN_STOP.name()}); try { Client client = MasterClient.getConnection(HdfsZooInstance.getInstance()); client.getMasterStats(Tracer.traceInfo(), SystemCredentials.get().getAsThrift()); } catch (Exception e) { // assume this is due to server shutdown break; } UtilWaitThread.sleep(1000);
Move this constructor to comply with Java Code Conventions.
@Deprecated
Remove this unused method parameter "ex".
public static void main(String[] args) { if (args.length != 5) { System.err.println("Usage: accumulo accumulo.examples.client.Flush <instance name> <zoo keepers> <username> <password> <tableName>"); return; } String instanceName = args[0]; String zooKeepers = args[1]; String user = args[2]; String password = args[3]; String table = args[4]; Connector connector; try { ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers); connector = instance.getConnector(user, password.getBytes()); connector.tableOperations().flush(table, null, null, true); } catch (Exception e) { throw new RuntimeException(e); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
assertEquals(k.getRow(), new Text(String.format("%09x", count + 1))); assertEquals(new String(v.get()), String.format("%09x", count)); assertEquals(splits.size(), 1); RangeInputSplit ris = new RangeInputSplit();
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
package org.apache.accumulo.examples.simple.shard;
Rename "table" which hides the field declared at line 107.
/** * * @since 1.6.0 */ BYTE(1l), KILOBYTE(1024l), MEGABYTE(1024 * 1024l), GIGABYTE(1024 * 1024 * 1024l); private final long multiplier; private MemoryUnit(long multiplier) { this.multiplier = multiplier; public long toBytes(long memory) { return memory * multiplier;
Cast one of the operands of this multiplication operation to a "long".
* 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. */ * Presently only supports next() and seek() and works on all the Map directories within a directory. The primary purpose of this class is to merge the results * of multiple Reduce jobs that result in Map output files. @SuppressWarnings({"rawtypes", "unchecked"}) * Reader reader; Writable value; boolean cached = false; private static Object create(java.lang.Class<?> klass) { if (!cached) return 1; if (!o.cached) return -1; public MultiReader(FileSystem fs, Configuration conf, String directory) throws IOException { if (child.getPath().getName().startsWith("_")) continue; if (!foundFinish) throw new IOException("Sort \"finished\" flag not found in " + directory); public synchronized boolean next(WritableComparable key, Writable val) throws IOException { WritableComparable found = index.reader.getClosest(key, index.value, true); if (problem != null) throw problem;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import static org.apache.accumulo.core.util.NumUtil.bigNumberForQuantity; return bigNumberForQuantity(i); return String.format("<span class='error'>%s</span>", bigNumberForQuantity(i)); return bigNumberForQuantity(i); return bigNumberForQuantity((long) i); return String.format("<span class='error'>%s</span>", bigNumberForQuantity(d)); return bigNumberForQuantity(d); return String.format("<span class='error'>%s</span>", bigNumberForQuantity(i)); return String.format("<span class='warning'>%s</span>", bigNumberForQuantity(i)); return bigNumberForQuantity(i); return String.format("<span class='error'>%s</span>", bigNumberForQuantity(d)); return String.format("<span class='warning'>%s</span>", bigNumberForQuantity(d)); return bigNumberForQuantity(d);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.examples.simple.mapreduce.bulk;
2 duplicated blocks of code must be removed.
/** * Sets the instance used by the shell based on the given options. * * @param options shell options */ // should only be one set of instance options set } else { String instanceName, hosts; if (options.isHdfsZooInstance()) { instanceName = hosts = null; instanceName = zkOpts.get(0); hosts = zkOpts.get(1); instanceName = options.getZooKeeperInstanceName(); hosts = options.getZooKeeperHosts(); } instance = getZooInstance(instanceName, hosts); private static Instance getZooInstance(String instanceName, String keepers) { UUID instanceId = null; if (instanceName == null || keepers == null) { @SuppressWarnings("deprecation") AccumuloConfiguration conf = AccumuloConfiguration.getSiteConfiguration(); if (instanceName == null) { instanceId = UUID.fromString(ZooUtil.getInstanceIDFromHdfs(instanceDir)); } if (keepers == null) { keepers = conf.get(Property.INSTANCE_ZK_HOST); } } if (instanceId != null) { return new ZooKeeperInstance(instanceId, keepers); } else { return new ZooKeeperInstance(instanceName, keepers); }
Move this variable to comply with Java Code Conventions.
TableInfo _val3; // required TableInfo _val14; // required
Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-z0-9]*)*$'.
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; m.put(TabletsSection.CurrentLocationColumnFamily.NAME, asColumnQualifier(), asMutationValue()); m.put(TabletsSection.FutureLocationColumnFamily.NAME, asColumnQualifier(), asMutationValue()); m.put(TabletsSection.LastLocationColumnFamily.NAME, asColumnQualifier(), asMutationValue()); m.putDelete(TabletsSection.LastLocationColumnFamily.NAME, asColumnQualifier());
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. */
296 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.
import org.apache.accumulo.core.util.MetadataTable; if (!moveMetadata && MetadataTable.NAME.equals(table))
Use "Long.toString" instead.
String useMock = props.getProperty("useMockInstance"); instance = new ZooKeeperInstance(props.getProperty("instance"), props.getProperty("zookeepers"));
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. */ public class SendSpansViaThrift extends AsyncSpanReceiver<String,Client> { private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SendSpansViaThrift.class); client.span(s); protected String getSpanKey(Map<String,String> data) { if (dest != null && dest.startsWith(THRIFT)) { if (hostAddr.length == 2) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.core.conf; public interface ConfigurationObserver { void propertyChanged(String key); void propertiesChanged(); void sessionExpired(); }
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. */ * public AggregatorConfiguration(Text columnFamily, String aggClassName) { super(columnFamily, aggClassName); } public AggregatorConfiguration(Text columnFamily, Text columnQualifier, String aggClassName) { super(columnFamily, columnQualifier, aggClassName); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.