Diff
stringlengths
10
2k
Message
stringlengths
28
159
protected static ByteBuffer userpass; userpass = tpc.proxy.login(new UserPass("root", ByteBuffer.wrap("".getBytes())));
Replace this use of System.out or System.err by a logger.
package org.apache.accumulo.test;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
if (node.name.equals(name)) return node; if (depth == path.length) return root; if (child == null) return null; if (node == null) return Collections.emptyList(); if (path.length == index) return root; if (parent == null) return; if (child != null) parent.children.remove(child); if (node != null) return node.value;
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. */ public Reader reserveMapFileReader(String mapFileName) throws IOException { Configuration conf = CachedConfiguration.getInstance(); FileSystem fs = FileSystem.get(conf); return new MyMapFile.Reader(fs, mapFileName, conf); } public AccumuloConfiguration getConfig() { return AccumuloConfiguration.getDefaultConfiguration(); } public IteratorScope getIteratorScope() { throw new UnsupportedOperationException(); } public boolean isFullMajorCompaction() { throw new UnsupportedOperationException(); } public void registerSideChannel(SortedKeyValueIterator<Key,Value> iter) { throw new UnsupportedOperationException(); }
Immediately return this expression instead of assigning it to the temporary variable "r".
import org.apache.accumulo.core.data.PartialKey; if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); acu.tables.get(tableName).setLocalityGroups(groups); if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); return acu.tables.get(tableName).getLocalityGroups(); if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); if (!exists(tableName)) throw new AccumuloException(tableName + " does not exists"); public void online(String tableName) throws AccumuloSecurityException, AccumuloException { if (!exists(tableName)) throw new AccumuloException(tableName + " does not exists"); } if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); } if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); MockTable t = acu.tables.get(tableName); Set<Key> keep = new TreeSet<Key>(t.table.tailMap(new Key(start)).headMap(new Key(end)).keySet()); t.table.keySet().removeAll(keep); if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); }
Use "Integer.toString" instead.
String file = key.getColumnQualifier().toString(); if (!file.startsWith("/")) file = "/" + file; Path map = new Path(ServerConstants.getTablesDir() + "/" + table + file);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * Internal class used to verify validity of data read. */ /** * Simple example for reading random batches of data from Accumulo. See docs/examples/README.batch for instructions. */ /** * Generate a number of ranges, each covering a single random row. * * @param num * the number of ranges to generate * @param min * the minimum row that will be generated * @param max * the maximum row that will be generated * @param r * a random number generator * @param ranges * a set in which to store the generated ranges * @param expectedRows * a map in which to store the rows covered by the ranges (initially mapped to false) */ /** * Prints a count of the number of rows mapped to false. * * @param expectedRows */ /** * Generates a number of random queries, verifies that the key/value pairs returned were in the queried ranges and that the values were generated by * {@link RandomBatchWriter#createValue(long, int)}. Prints information about the results. * * @param num * the number of queries to generate * @param min * the min row to query * @param max * the max row to query * @param evs * the expected size of the values * @param r * a random number generator * @param tsbr * a batch scanner */ /** * Scans over a specified number of entries to Accumulo using a {@link BatchScanner}. Completes scans twice to compare times for a fresh query with those for * a repeated query which has cached metadata and connections already established. * * @param args * @throws AccumuloException * @throws AccumuloSecurityException * @throws TableNotFoundException */
Replace this use of System.out or System.err by a logger.
return new MockInstanceOperations(acu);
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. */
Replace all tab characters in this file by sequences of white-spaces.
// TODO: Should we change this to an ArrayList so that we can just add() ? - ACCUMULO-1309 // TODO: Do I need to call new here? or can I just re-use the term? - ACCUMULO-1309
Make the "log" logger private static final and rename it to comply with the format "LOG(?:GER)?".
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, IOException, ConstraintViolationException { new BatchWriterConfig().setMaxMemory(Math.max(m.estimatedMemoryUsed(), 1024)).setMaxWriteThreads(1).setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS));
Return empty string instead.
import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
Replace all tab characters in this file by sequences of white-spaces.
} private void addOptions(StringBuilder sb, StatType selectedStatType) { for (StatType st : StatType.values()) { sb.append("<option").append(st.equals(selectedStatType) ? " selected='true'>" : ">").append(st.getDescription()).append("</option>"); } } private void doScript(StringBuilder sb, ArrayList<TabletServerStatus> tservers) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.util.TreeMap;
2 duplicated blocks of code must be removed.
package org.apache.accumulo.test.functional;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
for (String key : IteratorUtil.generateInitialTableProperties().keySet())
Remove this unused private "match" method.
public Repo<Master> call(long tid, Master master) throws Exception { String path = ZooUtil.getRoot(master.getInstance()) + Constants.ZTSERVERS + "/" + tserver; path = ZooUtil.getRoot(master.getInstance()) + Constants.ZDEADTSERVERS + "/" + tserver; zoo.putPersistentData(path, "forced down".getBytes(), NodeExistsPolicy.OVERWRITE); Listener listener = master.getEventCoordinator().getListener(); master.shutdownTServer(server); while (master.onlineTabletServers().contains(server)) { TServerConnection connection = master.getConnection(server); connection.halt(master.getMasterLock());
Remove this unused private "appendProp" method.
* * * * * *
Replace all tab characters in this file by sequences of white-spaces.
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; BatchWriterOpts bwOpts = new BatchWriterOpts(); BatchScannerOpts bsOpts = new BatchScannerOpts(); assertEquals(new Long(cfg.getMaxLatency(TimeUnit.MILLISECONDS)), bwOpts.batchLatency); assertEquals(new Long(cfg.getTimeout(TimeUnit.MILLISECONDS)), bwOpts.batchTimeout); assertEquals(new Long(cfg.getMaxMemory()), bwOpts.batchMemory); assertEquals(10, bsOpts.scanThreads.intValue()); JCommander jc = new JCommander(); jc.addObject(args); jc.addObject(bwOpts); jc.parse( "--help"); assertEquals(new Long(3000), bwOpts.batchLatency); assertEquals(new Long(2000), bwOpts.batchTimeout); assertEquals(new Long(1024*1024), bwOpts.batchMemory); assertEquals(7, bsOpts.scanThreads.intValue());
Remove this unused method parameter "opts".
package org.apache.accumulo.core.security; import java.io.Serializable; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.ColumnVisibility; public interface VisibilityInterpreter extends Serializable { public abstract String getAbbreviatedValue (); public abstract String getFullValue (); public abstract void merge(ColumnVisibility other, Authorizations authorizations); public abstract void merge(VisibilityInterpreter other); // Factory type method that can be used from an instance public abstract VisibilityInterpreter create (); public abstract VisibilityInterpreter create (ColumnVisibility visibility, Authorizations authorizations); }
Return empty string instead.
System.out.printf("mapType:%10s put rate:%,6.2f scan rate:%,6.2f get rate:%,6.2f delete time : %6.2f mem : %,d%n", "" + mapType, (numRows * numCols)
Use isEmpty() to check whether the collection is empty or not.
/** * Generate the initial (default) properties for a table * @param limitVersion * include a VersioningIterator at priority 20 that retains a single version of a given K/V pair. * @return A map of Table properties */ public static Map<String,String> generateInitialTableProperties(boolean limitVersion) { if (limitVersion) { for (IteratorScope iterScope : IteratorScope.values()) { props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers", "20," + VersioningIterator.class.getName()); props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers.opt.maxVersions", "1"); }
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 static void printMetaBlockInfo(Configuration conf, FileSystem fs, Path path) throws Exception { FSDataInputStream fsin = fs.open(path); BCFile.Reader bcfr = new BCFile.Reader(fsin, fs.getFileStatus(path).getLen(), conf); Set<Entry<String,MetaIndexEntry>> es = bcfr.metaIndex.index.entrySet(); for (Entry<String,MetaIndexEntry> entry : es) { PrintStream out = System.out; out.println("Meta block : " + entry.getKey()); out.println(" Raw size : " + String.format("%,d", entry.getValue().getRegion().getRawSize()) + " bytes"); out.println(" Compressed size : " + String.format("%,d", entry.getValue().getRegion().getCompressedSize()) + " bytes"); out.println(" Compression type : " + entry.getValue().getCompressionAlgorithm().getName()); out.println(); } } public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); @SuppressWarnings("deprecation") Path path = new Path(args[0]); printMetaBlockInfo(conf, fs, path); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.cli.BatchWriterOpts; import org.apache.accumulo.core.cli.ClientOpts; import org.apache.accumulo.core.cli.ScannerOpts; import com.beust.jcommander.Parameter; static class Opts extends ClientOpts { @Parameter(names="--shardTable") String shardTable = "shard"; @Parameter(names="--doc2Term") String doc2TermTable = "doc2Term"; } Opts opts = new Opts(); ScannerOpts scanOpts = new ScannerOpts(); BatchWriterOpts bwOpts = new BatchWriterOpts(); opts.parseArgs(Reverse.class.getName(), args, scanOpts, bwOpts); Connector conn = opts.getConnector(); Scanner scanner = conn.createScanner(opts.shardTable, opts.auths); scanner.setBatchSize(scanOpts.scanBatchSize); BatchWriter bw = conn.createBatchWriter(opts.doc2TermTable, bwOpts.getBatchWriterConfig());
Remove this unused private "appendProp" method.
ROW(1), ROW_COLFAM(2), ROW_COLFAM_COLQUAL(3), ROW_COLFAM_COLQUAL_COLVIS(4), ROW_COLFAM_COLQUAL_COLVIS_TIME(5), ROW_COLFAM_COLQUAL_COLVIS_TIME_DEL(6) // everything // with // delete // flag ; int depth; private PartialKey(int depth) { this.depth = depth; } public static PartialKey getByDepth(int depth) { for (PartialKey d : PartialKey.values()) if (depth == d.depth) return d; throw new IllegalArgumentException("Invalid legacy depth " + depth); } public int getDepth() { return depth; }
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. */ package org.apache.commons.vfs2.provider; import org.apache.commons.vfs2.FileSystem; import org.apache.commons.vfs2.FileSystemConfigBuilder; public class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder { private final static HdfsFileSystemConfigBuilder BUILDER = new HdfsFileSystemConfigBuilder(); private String hdfsUri = null; public String getHdfsUri() { return hdfsUri; } public void setHdfsUri(String hdfsUri) { this.hdfsUri = hdfsUri; } @Override protected Class<? extends FileSystem> getConfigClass() { return ReadOnlyHdfsFileSystem.class; } public static HdfsFileSystemConfigBuilder getInstance() { return BUILDER; } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * @deprecated since 1.4 */ /** * @deprecated since 1.4 */
6 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.wikisearch.iterator;
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.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); zk.putPersistentData(path, (reservationID + ":" + debugInfo).getBytes(utf8), NodeExistsPolicy.FAIL);
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. */
Replace all tab characters in this file by sequences of white-spaces.
currentRow = new Text(); currentDocID.set(emptyByteArray); doSeek(range, seekColumnFamilies, inclusive); } private void doSeek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive) throws IOException { log.debug("doSeek, topKey is outside of overall range: " + overallRange); return false; Range range = new Range(row); this.currentRow = row; this.currentDocID = new Text(this.getUID(jumpKey)); doSeek(range, seekColumnFamilies, false);
31 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.
} catch (TException e) { throw new IOException(e);
Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.
public class CachedBlock implements HeapSize, Comparable<CachedBlock>, CacheEntry { private Object index; @Override @Override public Object getIndex() { return index; } @Override public void setIndex(Object idx) { this.index = idx; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.util.ArrayList; import java.util.List; import org.apache.accumulo.core.cli.Help; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; static class TxOpts { @Parameter(description="<txid>", required=true) List<String> args = new ArrayList<String>(); } @Parameters(commandDescription="Stop an existing FATE by transaction id") static class FailOpts extends TxOpts { } @Parameters(commandDescription="Delete an existing FATE by transaction id") static class DeleteOpts extends TxOpts { } @Parameters(commandDescription="List the existing FATE transactions") static class PrintOpts { } Help opts = new Help(); JCommander jc = new JCommander(opts); jc.setProgramName(Admin.class.getName()); jc.addCommand("fail", new FailOpts()); jc.addCommand("delete", new DeleteOpts()); jc.addCommand("print", new PrintOpts()); jc.parse(args); if (opts.help || jc.getParsedCommand() == null) { jc.usage(); AdminUtil<Master> admin = new AdminUtil<Master>(); if (jc.getParsedCommand().equals("fail")) { admin.prepFail(zs, zk, masterPath, args[1]); } else if (jc.getParsedCommand().equals("delete")) { admin.prepDelete(zs, zk, masterPath, args[1]); } else if (jc.getParsedCommand().equals("print")) {
Remove this unused private "appendProp" method.
if (startRow == null && endRow == null) { 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; }
Move the "y" string literal on the left side of this string comparison.
import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; private boolean wait; private Option waitOpt; shellState.getConnector().tableOperations().offline(tableName, wait); Shell.log.info("Offline of table " + tableName + (wait ? " completed." : " initiated...")); @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { wait = cl.hasOption(waitOpt.getLongOpt()); return super.execute(fullCommand, cl, shellState); } @Override public Options getOptions() { final Options opts = super.getOptions(); waitOpt = new Option("w", "wait", false, "wait for offline to finish"); opts.addOption(waitOpt); return opts; }
Cast one of the operands of this multiplication operation to a "long".
import org.apache.accumulo.core.security.tokens.SecurityToken; public static synchronized TabletLocator getInstance(Instance instance, SecurityToken credentials, Text tableId) {
Either log or rethrow this exception.
import org.apache.accumulo.core.security.tokens.AccumuloToken; import org.apache.hadoop.fs.Path; * <li>{@link AccumuloInputFormat#setConnectorInfo(Job, AccumuloToken)} OR {@link AccumuloInputFormat#setConnectorInfo(Job, Path)}
Define and throw a dedicated exception instead of using a generic one.
shellState.getConnector().securityOperations().dropLocalUser(user);
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
/* * 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.server.test.randomwalk.concurrent; import java.util.List; import java.util.Map.Entry; import java.util.Properties; import java.util.Random; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.IsolatedScanner; import org.apache.accumulo.core.client.RowIterator; import org.apache.accumulo.core.client.TableDeletedException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.TableOfflineException; import org.apache.accumulo.core.data.Key; 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 IsolatedScan extends Test { @Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); try { RowIterator iter = new RowIterator(new IsolatedScanner(conn.createScanner(tableName, Constants.NO_AUTHS))); while(iter.hasNext()){ List<Entry<Key, Value>> row = iter.next(); for(int i=1; i < row.size(); i++) if(!row.get(0).getValue().equals(row.get(i).getValue())) throw new Exception("values not equal "+row.get(0)+" "+row.get(i)); } log.debug("Isolated scan "+tableName); } catch (TableDeletedException e){ log.debug("Isolated scan "+tableName+" failed, table deleted"); } catch (TableNotFoundException e) { log.debug("Isolated scan "+tableName+" failed, doesnt exist"); } catch (TableOfflineException e){ log.debug("Isolated scan "+tableName+" failed, offline"); } } }
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.
import org.apache.accumulo.fate.zookeeper.ZooReader;
Remove this call to "exit" or ensure it is really required.
package org.apache.accumulo.examples.simple.isolation;
Rename "table" which hides the field declared at line 107.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); store.put(Constants.ZROOT_TABLET_FUTURE_LOCATION, value.getBytes(utf8)); store.put(Constants.ZROOT_TABLET_LOCATION, value.getBytes(utf8)); store.put(Constants.ZROOT_TABLET_LAST_LOCATION, value.getBytes(utf8));
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.proxy.thrift.WriterOptions; int threads = 10; if (opts != null && opts.threads > 0) threads = opts.threads; BatchScanner scanner = connector.createBatchScanner(tableName, auth, threads); BatchWriter writer = getWriter(userpass, tableName, null); public String createWriter(UserPass userpass, String tableName, WriterOptions opts) throws TException { BatchWriter writer = getWriter(userpass, tableName, opts); private BatchWriter getWriter(UserPass userpass, String tableName, WriterOptions opts) throws Exception { BatchWriterConfig cfg = new BatchWriterConfig(); if (opts != null) { if (opts.maxMemory != 0) cfg.setMaxMemory(opts.maxMemory); if (opts.threads != 0) cfg.setMaxWriteThreads(opts.threads); if (opts.timeoutMs != 0) cfg.setTimeout(opts.timeoutMs, TimeUnit.MILLISECONDS); if (opts.latencyMs != 0) cfg.setMaxLatency(opts.latencyMs, TimeUnit.MILLISECONDS); } return getConnector(userpass).createBatchWriter(tableName, cfg);
Remove this unused import 'java.util.Arrays'.
assertEquals(0, exec(CacheTestWriter.class, "/zcTest-42", "/tmp/zcTest-42", "3","50").waitFor());
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. */
Replace all tab characters in this file by sequences of white-spaces.
return "Server Activity"; else if (size.equals("80")) spacing = 80; .append(spacing == 40 ? " selected='true'" : "").append(">40</option><option").append(spacing == 80 ? " selected='true'" : "") .append(">80</option></select></span>\n");
Move the "80" 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. */
Replace all tab characters in this file by sequences of white-spaces.
return authString == null ? Constants.NO_AUTHS : new Authorizations(authString.getBytes());
Move this constructor to comply with Java Code Conventions.
getConnector().securityOperations().createUser(TEST_USER, TEST_PASS.getBytes()); test_user_conn.securityOperations().createUser(user, password.getBytes()); root_conn.securityOperations().createUser(user, password.getBytes()); root_conn.securityOperations().createUser(user, password.getBytes()); test_user_conn.securityOperations().createUser(user, password.getBytes()); root_conn.securityOperations().createUser(user, password.getBytes()); root_conn.securityOperations().createUser(user, password.getBytes()); getConnector().securityOperations().createUser(TEST_USER, TEST_PASS.getBytes());
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
Connector conn = master.getConnector(); String tableDir = Constants.getMetadataTableDir(master.getConfiguration().getConfiguration()); public Repo<Master> call(long tid, Master master) throws Exception { MergeInfo mergeInfo = master.getMergeInfo(tableIdText); master.clearMergeState(tableIdText);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.server.util.MetadataTable; for (String cq : MetadataTable.getDataFileSizes(ke, token).keySet()) { files.add(ServerConstants.getTablesDir() + "/" + tableId + cq);
Either log or rethrow this exception.
package org.apache.accumulo.examples.aggregation; import java.util.TreeSet; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.aggregation.Aggregator; import org.apache.accumulo.core.util.StringUtil; public class SortedSetAggregator implements Aggregator { TreeSet<String> items = new TreeSet<String>(); // aggregate the entire set of items, in sorted order public Value aggregate() { return new Value(StringUtil.join(items, ",").getBytes()); } // allow addition of multiple items at a time to the set public void collect(Value value) { String[] strings = value.toString().split(","); for (String s : strings) items.add(s); } public void reset() { items.clear(); } }
Return empty string instead.
import jline.console.ConsoleReader; reader.println(itopts.getDescription()); reader.flush(); reader.println(); reader.println(Shell.repeat("-", 10) + "> entering options: " + desc); reader.flush(); reader.println(); reader.println("invalid options for " + clazz.getName());
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
void span(long traceId, long spanId, long parentId, long start, long stop, String description, Map<String,String> data); void flush();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (parts[1].isEmpty()) return new InetSocketAddress(parts[0], defaultPort);
Remove this call to "exit" or ensure it is really required.
private static VisibilityInterpreter interpreter = null; public static VisibilityInterpreter create() { if (interpreter == null) { throw new IllegalStateException("ColumnVisibilityInterpreterFactory is not configured: Interpreter is null"); return interpreter.create(); } public static VisibilityInterpreter create(ColumnVisibility cv, Authorizations authorizations) { if (interpreter == null) { throw new IllegalStateException("ColumnVisibilityInterpreterFactory is not configured: Interpreter is null"); return interpreter.create(cv, authorizations); } public static void setInterpreter(VisibilityInterpreter interpreter) { VisibilityInterpreterFactory.interpreter = interpreter; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
AccumuloInputFormat.setConnectorInfo(job, user, new PasswordToken(pass));
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 static void print(String fmt, Object... args) { * @throws TException List<TabletStats> onlineTabletsForTable = ThriftUtil.getTServerClient(args[0], ServerConfiguration.getSystemConfiguration()).getTabletStats(null, SecurityConstants.getSystemCredentials(), tableId);
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. */ package org.accumulo.maven.plugin; import org.apache.accumulo.minicluster.MiniAccumuloCluster; import org.apache.accumulo.minicluster.MiniAccumuloCluster.LogWriter; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; /** * Goal which stops all instances of {@link MiniAccumuloCluster} started with the start mojo. */ @Mojo(name = "stop", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST) public class StopMojo extends AbstractAccumuloMojo { @Override public void execute() throws MojoExecutionException { for (MiniAccumuloCluster mac : StartMojo.runningClusters) { System.out.println("Stopping MiniAccumuloCluster: " + mac.getInstanceName()); try { mac.stop(); for (LogWriter log : mac.getLogWriters()) log.flush(); } catch (Exception e) { throw new MojoExecutionException("Unable to start " + MiniAccumuloCluster.class.getSimpleName(), e); } } } }
Remove this hard-coded password.
Map<String,Long> lowBulkFiles = MetadataTable.getBulkFilesLoaded(SecurityConstants.getSystemCredentials(), low); Map<String,Long> highBulkFiles = MetadataTable.getBulkFilesLoaded(SecurityConstants.getSystemCredentials(), high); if (!lowBulkFiles.equals(highBulkFiles)) { throw new Exception(" " + lowBulkFiles + " != " + highBulkFiles + " " + low + " " + high); } if (lowBulkFiles.size() == 0) { throw new Exception(" no bulk files " + low); }
Define and throw a dedicated exception instead of using a generic one.
/* * 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.
} else assignments.put(mapFile, tabletsToAssignMapFileTo); if (tabletsToAssignMapFileTo.size() > 0) assignments.put(entry.getKey(), tabletsToAssignMapFileTo); if (fc == null) fc = 0; if (entry.getValue().size() == 0) afIter.remove(); if (client != null) ServerClient.close(client); if (t == Timers.TOTAL) continue; if (completeFailures.size() == 0) return Collections.emptySet(); if (start != null) start = Range.followingPrefix(start); if (row == null) row = new Text(); if (!reader.hasTop()) break; if (row != null && (endRow == null || row.compareTo(endRow) < 0)) row = Range.followingPrefix(row); else break; if (entry.getValue() > 0) tabletsImportedTo++; if (entry.getValue() < min) min = entry.getValue(); if (entry.getValue() > max) max = entry.getValue();
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.core.client.BatchWriterConfig; .createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
Remove this unused method parameter "e".
String[] parts = extractPartsFromAddress(address); static public InetSocketAddress parseAddress(String address) throws NumberFormatException { String[] parts = extractPartsFromAddress(address); if (parts.length == 2) return new InetSocketAddress(parts[0], Integer.parseInt(parts[1])); else throw new IllegalArgumentException("Address was expected to contain port. address=" + address); } static private String[] extractPartsFromAddress(String address) { String[] parts = address.split(":", 2); if (address.contains("+")) parts = address.split("\\+", 2); return parts; }
Immediately return this expression instead of assigning it to the temporary variable "client".
public static String join(Collection<String> strings, String sep) { int last = 0; StringBuilder ret = new StringBuilder(); for (String s : strings) { ret.append(s); last = ret.length(); ret.append(sep); ret.delete(last, ret.length()); return ret.toString(); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public class DeleteEverythingIT extends ConfigurableMacIT {
Use "Integer.toString" instead.
public class DynamicThreadPoolsIT extends ConfigurableMacIT { TCredentials creds = CredentialHelper.create("root", new PasswordToken(ROOT_PASSWORD), c.getInstance().getInstanceName());
Use "Integer.toString" instead.
package org.apache.accumulo.core.util; import junit.framework.TestCase; import org.apache.accumulo.core.util.TextUtil; import org.apache.hadoop.io.Text; /** * Test the TextUtil class. * */ public class TextUtilTest extends TestCase { /** * co */ public void testGetBytes(){ String longMessage = "This is some text"; Text longMessageText = new Text(longMessage); String smallerMessage = "a"; Text smallerMessageText = new Text(smallerMessage); Text someText = new Text(longMessage); assertTrue(someText.equals(longMessageText)); someText.set(smallerMessageText); assertTrue(someText.getLength() != someText.getBytes().length); assertTrue(TextUtil.getBytes(someText).length == smallerMessage.length()); assertTrue((new Text(TextUtil.getBytes(someText))).equals(smallerMessageText)); } }
Return empty string instead.
final byte[] password = p.getBytes();
Remove this unused method parameter "ex".
/* * 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. */ String indexTableName = (String) state.get("indexTableName"); int numPartitions = (Integer) state.get("numPartitions"); SortedSet<Text> splitSet = ShardFixture.genSplits(numPartitions, rand.nextInt(numPartitions) + 1, "%06x");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.trace.instrument.Tracer; import org.apache.accumulo.trace.thrift.TInfo; @Override public void unableToMonitorLockNode(Throwable e) { try { tch.halt(Tracer.traceInfo(), null, null); } catch (Exception ex) { log.error(ex, ex); System.exit(1); } }
Remove this call to "exit" or ensure it is really required.
private byte[] columnFamily; private byte[] columnQualifier; private byte[] columnVisibility; private long timestamp; private boolean hasTimestamp; private byte[] val; private byte[] data; private int tsOffset; private boolean deleted; public ColumnUpdate(byte[] cf, byte[] cq, byte[] cv, boolean hasts, long ts, boolean deleted, byte[] val, byte[] data, int tsOffset) { this.columnFamily = cf; this.columnQualifier = cq; this.columnVisibility = cv; this.hasTimestamp = hasts; this.timestamp = ts; this.deleted = deleted; this.val = val; this.data = data; this.tsOffset = tsOffset; } public void setSystemTimestamp(long v) { if (hasTimestamp) throw new IllegalStateException("Cannot set system timestamp when user set a timestamp"); int tso = this.tsOffset; data[tso++] = (byte) (v >>> 56); data[tso++] = (byte) (v >>> 48); data[tso++] = (byte) (v >>> 40); data[tso++] = (byte) (v >>> 32); data[tso++] = (byte) (v >>> 24); data[tso++] = (byte) (v >>> 16); data[tso++] = (byte) (v >>> 8); data[tso++] = (byte) (v >>> 0); this.timestamp = v; } public boolean hasTimestamp() { return hasTimestamp; } /** * Returns the column * */ public byte[] getColumnFamily() { return columnFamily; } public byte[] getColumnQualifier() { return columnQualifier; } public byte[] getColumnVisibility() { return columnVisibility; } public long getTimestamp() { return this.timestamp; } public boolean isDeleted() { return this.deleted; } public byte[] getValue() { return this.val; } public String toString() { return new String(Arrays.toString(columnFamily)) + ":" + new String(Arrays.toString(columnQualifier)) + " [" + new String(Arrays.toString(columnVisibility)) + "] " + (hasTimestamp ? timestamp : "NO_TIME_STAMP") + " " + Arrays.toString(val) + " " + deleted; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.util.FastFormat;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public HashMap<String, Object> getMap() { return stateMap; }
Immediately return this expression instead of assigning it to the temporary variable "res".
private static final int TSERV_MINC_MAXCONCURRENT_NUMWAITING_MULTIPLIER = 2; @Override numWaitingMultiplier = TSERV_MINC_MAXCONCURRENT_NUMWAITING_MULTIPLIER;
Use "Long.toString" instead.
package normalizer; import static org.junit.Assert.assertTrue; import org.junit.Test; public class testNumberNormalizer { @Test public void test1() throws Exception { NumberNormalizer nn = new NumberNormalizer(); String n1 = nn.normalizeFieldValue(null, "1"); String n2 = nn.normalizeFieldValue(null, "1.00000000"); assertTrue( n1.compareTo(n2) < 0); } @Test public void test2() { NumberNormalizer nn = new NumberNormalizer(); String n1 = nn.normalizeFieldValue(null, "-1.0"); String n2 = nn.normalizeFieldValue(null, "1.0"); assertTrue( n1.compareTo(n2) < 0 ); } @Test public void test3(){ NumberNormalizer nn = new NumberNormalizer(); String n1 = nn.normalizeFieldValue(null, "-0.0001"); String n2 = nn.normalizeFieldValue(null, "0"); String n3 = nn.normalizeFieldValue(null, "0.00001"); assertTrue((n1.compareTo(n2) < 0) && (n2.compareTo(n3) < 0)); } @Test public void test4(){ NumberNormalizer nn = new NumberNormalizer(); String nn1 = nn.normalizeFieldValue(null, Integer.toString(Integer.MAX_VALUE)); String nn2 = nn.normalizeFieldValue(null, Integer.toString(Integer.MAX_VALUE-1)); assertTrue( (nn2.compareTo(nn1) < 0)); } @Test public void test5(){ NumberNormalizer nn = new NumberNormalizer(); String nn1 = nn.normalizeFieldValue(null, "-0.001"); String nn2 = nn.normalizeFieldValue(null, "-0.0009"); String nn3 = nn.normalizeFieldValue(null, "-0.00090"); assertTrue((nn3.compareTo(nn2) == 0) && (nn2.compareTo(nn1) > 0)); } @Test public void test6(){ NumberNormalizer nn = new NumberNormalizer(); String nn1 = nn.normalizeFieldValue(null, "00.0"); String nn2 = nn.normalizeFieldValue(null, "0"); String nn3 = nn.normalizeFieldValue(null, "0.0"); assertTrue((nn3.compareTo(nn2) == 0) && (nn2.compareTo(nn1) == 0)); } }
Return empty string instead.
public enum PartialKey implements org.apache.thrift.TEnum { private PartialKey(int value) { public static PartialKey findByValue(int value) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* @since 1.5.0
Move this constructor to comply with Java Code Conventions.
import org.apache.accumulo.core.security.Credentials; public static boolean getBatchFromServer(Instance instance, Credentials credentials, Range range, KeyExtent extent, String server, SortedMap<Key,Value> results, SortedSet<Column> fetchedColumns, List<IterInfo> serverSideIteratorList, Map<String,Map<String,String>> serverSideIteratorOptions, int size, Authorizations authorizations, boolean retry, AccumuloConfiguration conf) throws AccumuloException, AccumuloSecurityException, NotServingTabletException { ScanState scanState = new ScanState(instance, credentials, extent.getTableId(), authorizations, range, fetchedColumns, size, serverSideIteratorList, InitialScan isr = client.startScan(tinfo, scanState.credentials.toThrift(instance), extent.toThrift(), scanState.range.toThrift(), Instance instance; Credentials credentials; public ScanState(Instance instance, Credentials credentials, Text tableId, Authorizations authorizations, Range range, SortedSet<Column> fetchedColumns, int size, List<IterInfo> serverSideIteratorList, Map<String,Map<String,String>> serverSideIteratorOptions, boolean isolated) { this.instance = instance; public static List<KeyValue> scan(Instance instance, Credentials credentials, ScanState scanState, int timeOut, AccumuloConfiguration conf) loc = TabletLocator.getLocator(instance, scanState.tableId).locateTablet(credentials, scanState.startRow, scanState.skipStartRow, false); InitialScan is = client.startScan(tinfo, scanState.credentials.toThrift(scanState.instance), loc.tablet_extent.toThrift(), scanState.range.toThrift(),
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
* 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 DropTableCommand extends DeleteTableCommand {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
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.
System.out.printf(" %-" + NAME_WIDTH + "s| %-" + UUID_WIDTH + "s| %-" + MASTER_WIDTH + "s%n", "Instance Name", "Instance ID", "Master"); System.out.printf("%" + (NAME_WIDTH + 1) + "s+%" + (UUID_WIDTH + 1) + "s+%" + (MASTER_WIDTH + 1) + "s%n", new CharFiller('-'), new CharFiller('-'), System.out.printf("%" + NAME_WIDTH + "s |%" + UUID_WIDTH + "s |%" + MASTER_WIDTH + "s%n", "\"" + instanceName + "\"", iid, master);
Use isEmpty() to check whether the collection is empty or not.
package org.apache.accumulo.server.tabletserver; public class CompactionStats { private long entriesRead; private long entriesWritten; private long fileSize; CompactionStats(long er, long ew){ this.setEntriesRead(er); this.setEntriesWritten(ew); } public CompactionStats() { } private void setEntriesRead(long entriesRead) { this.entriesRead = entriesRead; } public long getEntriesRead() { return entriesRead; } private void setEntriesWritten(long entriesWritten) { this.entriesWritten = entriesWritten; } public long getEntriesWritten() { return entriesWritten; } public void add(CompactionStats mcs) { this.entriesRead += mcs.entriesRead; this.entriesWritten += mcs.entriesWritten; } public void setFileSize(long fileSize) { this.fileSize = fileSize; } public long getFileSize(){ return this.fileSize; } }
Return empty string instead.
import org.apache.accumulo.cloudtrace.instrument.Trace;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
throw new IllegalArgumentException("no type specified"); throw new IllegalArgumentException();
Complete the task associated to this TODO comment.
private static final Logger log = Logger.getLogger(DumpMapFile.class); public static void main(String[] args) { try { Configuration conf = CachedConfiguration.getInstance(); FileSystem fs = FileSystem.get(conf); MyMapFile.Reader mr = new MyMapFile.Reader(fs, args[0], conf); Key key = new Key(); Value value = new Value(); long start = System.currentTimeMillis(); while (mr.next(key, value)) { log.info(key + " -> " + value); } long stop = System.currentTimeMillis(); log.info(stop - start); } catch (IOException e) { throw new RuntimeException(e); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* Gets the serialized token class from either the configuration or the token file. * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. @Deprecated return getAuthenticationToken(job).getClass().getName(); * Gets the serialized token from either the configuration or the token file. * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. @Deprecated return AuthenticationTokenSerializer.serialize(getAuthenticationToken(job)); * Gets the authenticated token from either the specified token file or directly from the configuration, whichever was used when the job was configured. * @return the principal's authentication token * @see #setConnectorInfo(JobConf, String, String) protected static AuthenticationToken getAuthenticationToken(JobConf job) { return InputConfigurator.getAuthenticationToken(CLASS, job); AuthenticationToken token = getAuthenticationToken(job); Connector conn = instance.getConnector(user, token); scanner = new OfflineScanner(instance, new Credentials(user, token), Tables.getTableId(instance, getInputTableName(job)), authorizations); Connector conn = instance.getConnector(getPrincipal(job), getAuthenticationToken(job)); while (!tl.binRanges(new Credentials(getPrincipal(job), getAuthenticationToken(job)), ranges, binnedRanges).isEmpty()) {
This block of commented-out lines of code should be removed.
package org.apache.accumulo.core.util.shell.commands; import java.io.IOException; import java.util.Map; import java.util.Set; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.TableNotFoundException; 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; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; public class DeleteTableCommand extends Command { private Option tableOpt; public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, IOException { String tableName = cl.getArgs()[0]; if (!shellState.getConnector().tableOperations().exists(tableName)) throw new TableNotFoundException(null, tableName, null); shellState.getConnector().tableOperations().delete(tableName); shellState.getReader().printString("Table: [" + tableName + "] has been deleted. \n"); if (shellState.getTableName().equals(tableName)) shellState.setTableName(""); return 0; } @Override public String description() { return "deletes a table"; } @Override public void registerCompletion(Token root, Map<Command.CompletionSet, Set<String>> special) { registerCompletionForTables(root, special); } @Override public String usage() { return getName() + " <tableName>"; } @Override public Options getOptions() { Options o = new Options(); tableOpt = new Option (Shell.tableOption, "tableName", true , "deletes a table"); o.addOption(tableOpt); return o; } @Override public int numArgs() { return 1; } }
Return empty string instead.
this(username, new MockAccumulo(MockInstance.getDefaultFileSystem()), instance);
Either log or rethrow this exception.
import org.apache.accumulo.core.iterators.user.NoVisFilter; import org.apache.accumulo.core.iterators.user.RegExFilter; import org.apache.accumulo.core.iterators.user.VersioningIterator; classname = RegExFilter.class.getName(); classname = NoVisFilter.class.getName();
Remove this unused private "match" method.
import org.apache.accumulo.core.security.thrift.Credential; void send(Credential info, String serverName, MasterClientService.Iface client) throws TException, ThriftSecurityException;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.cli.BatchScannerOpts; BatchScannerOpts bsOpts = new BatchScannerOpts(); opts.parseArgs(RandomBatchScanner.class.getName(), args, bsOpts); BatchScanner batchReader = connector.createBatchScanner(opts.tableName, opts.auths, bsOpts.scanThreads); batchReader.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS); doRandomQueries(opts.num, opts.min, opts.max, opts.size, r, batchReader); doRandomQueries(opts.num, opts.min, opts.max, opts.size, r, batchReader); batchReader.close();
Remove this unused method parameter "opts".