Diff
stringlengths
10
2k
Message
stringlengths
28
159
/** * @deprecated */
6 duplicated blocks of code must be removed.
public static void main(String[] args) { System.out.println(getPlatform()); } public static String getPlatform() { return (System.getProperty("os.name") + "-" + System.getProperty("os.arch") + "-" + System.getProperty("sun.arch.data.model")).replace(' ', '_'); }
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.
import java.util.Map; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.server.client.HdfsZooInstance; import org.apache.accumulo.server.security.SecurityConstants; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; import org.apache.hadoop.io.DataInputBuffer; import org.apache.zookeeper.data.Stat; public static void main(String[] args) throws Exception { Instance instance = HdfsZooInstance.getInstance(); Map<String,String> tableIdMap = instance.getConnector(SecurityConstants.getSystemCredentials()).tableOperations().tableIdMap(); for (String tableId : tableIdMap.keySet()) { String path = ZooUtil.getRoot(instance.getInstanceID()) + Constants.ZTABLES + "/" + tableId.toString() + "/merge"; MergeInfo info = new MergeInfo(); if (ZooReaderWriter.getInstance().exists(path)) { byte[] data = ZooReaderWriter.getInstance().getData(path, new Stat()); DataInputBuffer in = new DataInputBuffer(); in.reset(data, data.length); info.readFields(in); } System.out.println(String.format("%25s %10s %10s %s", tableIdMap.get(tableId), info.state, info.operation, info.range)); } }
Extract the assignment out of this expression.
AccumuloInputFormat.setInputInfo(job, user, pass.getBytes(), table1, Constants.NO_AUTHS); AccumuloInputFormat.setMockInstance(job, "testmrinstance"); AccumuloOutputFormat.setOutputInfo(job, user, pass.getBytes(), false, table2); AccumuloOutputFormat.setMockInstance(job, "testmrinstance");
Move this variable to comply with Java Code Conventions.
public static class TestOutputStream extends OutputStream {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.core.util.shell.commands; import java.io.IOException; import java.util.Map; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.util.shell.Shell; 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 TablesCommand extends Command { private Option tableIdOption; @Override public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException { if (cl.hasOption(tableIdOption.getOpt())) { Map<String, String> tableIds = shellState.getConnector().tableOperations().tableIdMap(); for (String tableName : shellState.getConnector().tableOperations().list()) shellState.getReader().printString(String.format("%-15s => %10s\n", tableName, tableIds.get(tableName))); } else { for (String table : shellState.getConnector().tableOperations().list()) shellState.getReader().printString(table + "\n"); } return 0; } @Override public String description() { return "displays a list of all existing tables"; } @Override public Options getOptions() { Options o = new Options(); tableIdOption = new Option("l", "list-ids", false, "display internal table ids along with the table name"); o.addOption(tableIdOption); return o; } @Override public int numArgs() { return 0; } }
Return empty string instead.
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; assertEquals(mockInstance, mockInstance.getConnector("foo", "bar").getInstance()); assertEquals(name, mockInstance.getConnector("foo","bar").getInstance().getInstanceName());
6 duplicated blocks of code must be removed.
import org.apache.log4j.Logger; static class LoggingTimerTask extends TimerTask { private Runnable task; LoggingTimerTask(Runnable task) { this.task = task; } @Override public void run() { try { task.run(); } catch (Throwable t) { Logger.getLogger(LoggingTimerTask.class).warn("Timer task failed " + task.getClass().getName() + " " + t.getMessage(), t); } } } public void schedule(Runnable task, long delay) { timer.schedule(new LoggingTimerTask(task), delay); public void schedule(Runnable task, long delay, long period) { timer.schedule(new LoggingTimerTask(task), delay, period);
Return empty string instead.
import org.apache.accumulo.core.iterators.user.ReqVisFilter; private Option aggTypeOpt, ageoffTypeOpt, regexTypeOpt, versionTypeOpt, reqvisTypeOpt, classnameTypeOpt; else if (cl.hasOption(reqvisTypeOpt.getOpt())) classname = ReqVisFilter.class.getName(); reqvisTypeOpt = new Option("reqvis", "require-visibility", false, "a type that omits entries with empty visibilities"); typeGroup.addOption(reqvisTypeOpt);
Either log or rethrow this exception.
package org.apache.accumulo.examples.wikisearch.parser; import org.apache.accumulo.examples.wikisearch.parser.QueryParser.QueryTerm; import org.apache.accumulo.examples.wikisearch.parser.RangeCalculator.RangeBounds;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper; InstanceTokenWrapper source;
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. */ package org.apache.accumulo.core.cli; import com.beust.jcommander.Parameter; public class ClientOnDefaultTable extends ClientOpts { private final String defaultTable; public ClientOnDefaultTable(String table) { this.defaultTable = table; } @Parameter(names="--table", description="table to use") String tableName; public String getTableName() { if (tableName == null) return defaultTable; return tableName; } }
Remove this call to "exit" or ensure it is really required.
TKeyValue _elem18; // required TRange _elem25; // required TKeyExtent _elem28; // required TKeyValue _elem39; // required TRange _elem46; // required TKeyExtent _elem49; // required
Remove this unused method parameter "table".
package org.apache.accumulo.test;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
import org.apache.accumulo.core.security.tokens.AuthenticationToken; * @throws AccumuloSecurityException public static void setConnectorInfo(Job job, String principal, AuthenticationToken token) throws AccumuloSecurityException { * @see #setConnectorInfo(Job, String, AuthenticationToken) * @see #setConnectorInfo(Job, String, AuthenticationToken) OutputConfigurator.setConnectorInfo(CLASS, conf, user, new PasswordToken(passwd));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.examples.simple.filedata;
2 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. */ package org.apache.accumulo.minicluster; /** * Opaque handle to a process. */ public class ProcessReference { private Process process; ProcessReference(Process process) { this.process = process; } @Override public String toString() { return process.toString(); } @Override public int hashCode() { return process.hashCode(); } @Override public boolean equals(Object obj) { return process.equals(obj); } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@Test(timeout=30*1000)
Use "Integer.toString" instead.
import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.aggregation.Aggregator; @SuppressWarnings("deprecation")
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. */ super(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), watcher);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private Option noFlushOption, waitOpt; startRow = OptUtil.getStartRow(cl); endRow = OptUtil.getEndRow(cl); opts.addOption(OptUtil.startRowOpt()); opts.addOption(OptUtil.endRowOpt());
Either log or rethrow this exception.
* The program reads an accumulo table written by {@link Index} and writes out to another table. It writes out a mapping of documents to terms. The document to * term mapping is used by {@link ContinuousQuery}. * See docs/examples/README.shard for instructions.
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. */ * A MemoryManager in accumulo currently determines when minor compactions should occur and when ingest should be put on hold. The goal of a memory manager * implementation is to maximize ingest throughput and minimize the number of minor compactions. * /** * An implementation of this function will be called periodically by accumulo and should return a list of tablets to minor compact. * * Instructing a tablet that is already minor compacting (this can be inferred from the TabletState) to minor compact has no effect. * * Holding all ingest does not affect metadata tablets. */ MemoryManagementActions getMemoryManagementActions(List<TabletState> tablets); /** * This method is called when a tablet is closed. A memory manger can clean up any per tablet state it is keeping when this is called. */ void tabletClosed(KeyExtent extent);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.thrift.SecurityErrorCode; import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException; /* UNLOAD_ROOT_TABLET */ {_, _, _, X, _, X, X}, KeyExtent oldTablet = new KeyExtent(split.oldTablet); if (migrations.remove(oldTablet) != null) { } catch (NotServingTabletException e) { log.debug("Error asking tablet server to split a tablet: " + e); setMasterState(MasterState.NORMAL); TServerConnection connection = tserverSet.getConnection(server); if (connection == null) throw new IOException("No connection to " + server); TabletServerStatus status = connection.getTableMap();
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
String _val51; // required String _val57; // required String _val61; // required String _val67; // required
Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-z0-9]*)*$'.
private static final Logger log = Logger.getLogger(VolumeManagerImpl.class);
Rename the "log" logger to comply with the format "LOG(?:GER)?".
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException { for (String p : TablePermission.printableValues()) { }
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.util.shell.Token;
Replace all tab characters in this file by sequences of white-spaces.
* 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, __LASTSTATUS_ISSET_ID); return EncodingUtils.testBit(__isset_bitfield, __LASTSTATUS_ISSET_ID); __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __LASTSTATUS_ISSET_ID, value); // check for sub-struct validity __isset_bitfield = 0;
Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.
package util; import java.util.HashMap; import java.util.Map; import org.apache.accumulo.core.data.Key; public class BaseKeyParser { public static final String ROW_FIELD = "row"; public static final String COLUMN_FAMILY_FIELD = "columnFamily"; public static final String COLUMN_QUALIFIER_FIELD = "columnQualifier"; protected Map <String, String> keyFields = new HashMap <String, String> (); protected Key key = null; /** * Parses a Key object into its constituent fields. This method * clears any prior values, so the object can be reused * without requiring a new instantiation. This default implementation * makes the row, columnFamily, and columnQualifier available. * * @param key */ public void parse (Key key) { this.key = key; keyFields.clear(); keyFields.put (ROW_FIELD, key.getRow().toString()); keyFields.put (COLUMN_FAMILY_FIELD, key.getColumnFamily().toString()); keyFields.put (COLUMN_QUALIFIER_FIELD, key.getColumnQualifier().toString()); } public String getFieldValue (String fieldName) { return keyFields.get(fieldName); } public String[] getFieldNames() { String[] fieldNames = new String[keyFields.size()]; return keyFields.keySet().toArray(fieldNames); } public BaseKeyParser duplicate () { return new BaseKeyParser(); } public String getRow() { return keyFields.get(ROW_FIELD); } public String getColumnFamily () { return keyFields.get(COLUMN_FAMILY_FIELD); } public String getColumnQualifier() { return keyFields.get(COLUMN_QUALIFIER_FIELD); } public Key getKey() { return this.key; } }
Return empty string instead.
package org.apache.accumulo.core.util.shell.commands; public class DropTableCommand extends DeleteTableCommand { }
Return empty string instead.
long diff = 0, diff2 = 0; // try the speed test a couple times in case the system is loaded with other tests for (int i = 0; i < 2; i++) { long now = System.currentTimeMillis(); assertEquals(0, cluster.exec(RandomBatchScanner.class,"--seed", "7", "-i", instance, "-z", keepers, "-u", user, "-p", ROOT_PASSWORD, "--num", "10000", "--min", "0", "--max", "1000000000", "--size", "50", "--scanThreads", "4","-t", "bloom_test").waitFor()); diff = System.currentTimeMillis() - now; now = System.currentTimeMillis(); assertEquals(0, cluster.exec(RandomBatchScanner.class,"--seed", "8", "-i", instance, "-z", keepers, "-u", user, "-p", ROOT_PASSWORD, "--num", "10000", "--min", "0", "--max", "1000000000", "--size", "50", "--scanThreads", "4","-t", "bloom_test").waitFor()); diff2 = System.currentTimeMillis() - now; if (diff2 < diff) break; }
Either log or rethrow this exception.
@Override public List<DiskUsage> getDiskUsage(Set<String> tables) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { return null; }
Either log or rethrow this exception.
if (pkey == null) return null;
Use "Integer.toString" instead.
if (!"true".equals(state.get("bulkImportSuccess"))) { log.info("Not verifying bulk import test due to import failures"); return; }
Either log or rethrow this exception.
@Override @Deprecated
3 duplicated blocks of code must be removed.
private Option optStartRow, optEndRow, forceOpt; String tableName = OptUtil.configureTableOpt(cl, shellState); o.addOption(OptUtil.tableOpt("table to delete a row range from"));
Reduce this switch case number of lines from 8 to at most 5, for example by extracting code into methods.
@Deprecated
Return empty string instead.
if (opt.equals(AUTH_OPT)) { seekRange = new Range(range);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
String[] tablePropsToDelete = new String[] {"table.scan.cache.size", "table.scan.cache.enable"}; for (String prop : tablePropsToDelete) { String propPath = ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + id + Constants.ZTABLE_CONF + "/" + prop; if (zoo.exists(propPath)) zoo.delete(propPath, -1); }
Remove this unused method parameter "hasStart".
package org.apache.accumulo.core.file.keyfunctor; import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.PartialKey; import org.apache.accumulo.core.data.Range; import org.apache.hadoop.util.bloom.Key; public class ColumnFamilyFunctor implements KeyFunctor{ public static final PartialKey kDepth = PartialKey.ROW_COLFAM; @Override public org.apache.hadoop.util.bloom.Key transform(org.apache.accumulo.core.data.Key acuKey) { byte keyData[]; ByteSequence row = acuKey.getRowData(); ByteSequence cf = acuKey.getColumnFamilyData(); keyData = new byte[row.length()+cf.length()]; System.arraycopy(row.getBackingArray(), row.offset(), keyData, 0, row.length()); System.arraycopy(cf.getBackingArray(), cf.offset(), keyData, row.length(), cf.length()); return new org.apache.hadoop.util.bloom.Key(keyData,1.0); } @Override public Key transform(Range range) { if(RowFunctor.isRangeInBloomFilter(range, PartialKey.ROW_COLFAM)){ return transform(range.getStartKey()); } return null; } }
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.
Connector conn = mi.getConnector("root", "");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.test.randomwalk.unit; 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.core.security.Authorizations; Scanner scanner = new IsolatedScanner(conn.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY));
Remove this unused method parameter "range".
@SuppressWarnings("all") public class ClientService {
13 duplicated blocks of code must be removed.
EnumMap<K,Long> startTime; EnumMap<K,Long> totalTime; public StopWatch(Class<K> k) { startTime = new EnumMap<K,Long>(k); totalTime = new EnumMap<K,Long>(k); } public synchronized void start(K timer) { if (startTime.containsKey(timer)) { throw new IllegalStateException(timer + " already started"); startTime.put(timer, System.currentTimeMillis()); } public synchronized void stopIfActive(K timer) { if (startTime.containsKey(timer)) stop(timer); } public synchronized void stop(K timer) { Long st = startTime.get(timer); if (st == null) { throw new IllegalStateException(timer + " not started"); Long existingTime = totalTime.get(timer); if (existingTime == null) existingTime = 0L; totalTime.put(timer, existingTime + (System.currentTimeMillis() - st)); startTime.remove(timer); } public synchronized void reset(K timer) { totalTime.remove(timer); } public synchronized long get(K timer) { Long existingTime = totalTime.get(timer); if (existingTime == null) existingTime = 0L; return existingTime; } public synchronized double getSecs(K timer) { Long existingTime = totalTime.get(timer); if (existingTime == null) existingTime = 0L; return existingTime / 1000.0; } public synchronized void print() { for (K timer : totalTime.keySet()) { System.out.printf("%20s : %,6.4f secs\n", timer.toString(), get(timer) / 1000.0); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
protected final Logger log = Logger.getLogger(this.getClass()); public static class SeqMapClass extends Mapper<Key,Value,Text,Mutation> { public void map(Key key, Value val, Context output) throws IOException, InterruptedException { Mutation m = new Mutation(key.getRow()); m.put(key.getColumnFamily(), key.getColumnQualifier(), val); output.write(null, m); } public int run(String[] args) throws Exception { Job job = new Job(getConf(), this.getClass().getSimpleName()); job.setJarByClass(this.getClass()); if (job.getJar() == null) { log.error("M/R requires a jar file! Run mvn package."); return 1; job.setInputFormatClass(AccumuloInputFormat.class); AccumuloInputFormat.setInputInfo(job, args[0], args[1].getBytes(), args[2], new Authorizations()); AccumuloInputFormat.setZooKeeperInstance(job, args[3], args[4]); job.setMapperClass(SeqMapClass.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(Mutation.class); job.setNumReduceTasks(0); job.setOutputFormatClass(AccumuloOutputFormat.class); AccumuloOutputFormat.setOutputInfo(job, args[0], args[1].getBytes(), true, args[5]); AccumuloOutputFormat.setZooKeeperInstance(job, args[3], args[4]); job.waitForCompletion(true); return job.isSuccessful() ? 0 : 1; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.server.test.randomwalk.concurrent; import java.util.Iterator; 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.Scanner; 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 ScanTable 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 { Scanner scanner = conn.createScanner(tableName, Constants.NO_AUTHS); Iterator<Entry<Key, Value>> iter = scanner.iterator(); while(iter.hasNext()){ iter.next(); } log.debug("Scanned "+tableName); } catch (TableDeletedException e){ log.debug("Scan "+tableName+" failed, table deleted"); } catch (TableNotFoundException e) { log.debug("Scan "+tableName+" failed, doesnt exist"); } catch (TableOfflineException e){ log.debug("Scan "+tableName+" failed, offline"); } } }
Return empty string instead.
public Map<String,EnumSet<IteratorScope>> listIterators(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.trace.instrument.impl;
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
Constants.METADATA_PREV_ROW_COLUMN.fetch(scanner);
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException; TabletLocationState tls; try { tls = MetaDataTableScanner.createTabletLocationState(entry.getKey(), entry.getValue()); } catch (BadLocationStateException e) { log.error(e, e); return false; }
Either log or rethrow this exception.
/** * Closes any underlying connections on the scanner */ public void close();
Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.
/* * 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.
if (update.isSetDeleteCell()) { m.putDelete(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz); } else { m.put(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz, new Value(value)); }
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 String username; public byte[] password;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
TabletClientService.Iface client = ThriftUtil.getTServerClient(location, instance.getConfiguration(), Property.TSERV_CLIENTPORT, Property.TSERV_BULK_TIMEOUT);
Reorder the modifiers to comply with the Java Language Specification.
import org.apache.accumulo.core.security.tokens.PasswordToken; import org.apache.accumulo.core.security.tokens.SecurityToken;
Replace all tab characters in this file by sequences of white-spaces.
* This setting determines how long a scanner will automatically retry when a failure occurs. By default a scanner will retry forever. * * @param timeOut * in seconds * @deprecated Since 1.5. See {@link ScannerBase#setTimeout(long, java.util.concurrent.TimeUnit)} */ @Deprecated public void setTimeOut(int timeOut); /** * Returns the setting for how long a scanner will automatically retry when a failure occurs. * * @return the timeout configured for this scanner * @deprecated Since 1.5. See {@link ScannerBase#getTimeout(java.util.concurrent.TimeUnit)} */ @Deprecated public int getTimeOut(); /**
Move this constructor to comply with Java Code Conventions.
if (userExists) throw new AccumuloException("User didn't exist when they should (or worse- password mismatch)", ae); else return; if (!auths.contains(k.getColumnVisibilityData())) throw new AccumuloException("Got data I should not be capable of seeing"); if (!canRead) throw new AccumuloException("Was able to read when I shouldn't have had the perm with connection user " + conn.whoami()); if (auths.contains(entry.getKey().getBytes())) seen = seen - entry.getValue(); if (seen != 0) throw new AccumuloException("Got mismatched amounts of data"); if (tableExists) throw new AccumuloException("Accumulo and test suite out of sync", tnfe); if (canRead) throw new AccumuloException("Table read permission out of sync with Accumulo", ae); else return; if (canRead) throw new AccumuloException("Table read permission out of sync with Accumulo", re.getCause()); else return; if (tableExists) throw new AccumuloException("Table didn't exist when it should have"); if (works) for (String s : SecurityHelper.getAuthsArray()) SecurityHelper.increaseAuthMap(state, s, 1); if (tableExists) throw new AccumuloException("Table didn't exist when it should have"); if (hasPerm) throw new AccumuloException("Bulk Import failed when it should have worked."); if (!hasPerm) throw new AccumuloException("Bulk Import succeeded when it should have failed.");
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.server.zookeeper.IZooReaderWriter; IZooReaderWriter zk = ZooReaderWriter.getInstance(); IZooReaderWriter zk = ZooReaderWriter.getInstance();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; public class VersioningIteratorTest { @Test @Test VersioningIterator it = new VersioningIterator(); IteratorSetting is = new IteratorSetting(1, VersioningIterator.class); VersioningIterator.setMaxVersions(is, 3); it.init(new SortedMapIterator(tm), is.getProperties(), null); @Test @Test @Test @Test public void test6() throws IOException { Text colf = new Text("a"); Text colq = new Text("b"); TreeMap<Key,Value> tm = new TreeMap<Key,Value>(); createTestData(tm, colf, colq); VersioningIterator it = new VersioningIterator(); IteratorSetting is = new IteratorSetting(1, VersioningIterator.class); VersioningIterator.setMaxVersions(is, 3); it.init(new SortedMapIterator(tm), is.getProperties(), null); VersioningIterator it2 = it.deepCopy(null); Key seekKey = new Key(new Text(String.format("%03d", 1)), colf, colq, 19); it.seek(new Range(seekKey, false, null, true), EMPTY_COL_FAMS, false); it2.seek(new Range(seekKey, false, null, true), EMPTY_COL_FAMS, false); assertTrue(it.hasTop()); assertTrue(it.getTopKey().getTimestamp() == 18); assertTrue(it2.hasTop()); assertTrue(it2.getTopKey().getTimestamp() == 18); }
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.
import org.apache.accumulo.core.security.thrift.TCredentials; import org.apache.accumulo.core.security.tokens.AuthenticationToken; private static final AuthenticationToken SYSTEM_TOKEN = makeSystemPassword(); private static final TCredentials systemCredentials = CredentialHelper.createSquelchError(SYSTEM_PRINCIPAL, SYSTEM_TOKEN, HdfsZooInstance.getInstance() .getInstanceID()); public static AuthenticationToken getSystemToken() { public static TCredentials getSystemCredentials() { private static AuthenticationToken makeSystemPassword() { return new PasswordToken(Base64.encodeBase64(bytes.toByteArray()));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* <li>{@link AccumuloInputFormat#setConnectorInfo(JobConf, String, AuthenticationToken)}
3 duplicated blocks of code must be removed.
import org.apache.accumulo.proxy.thrift.IteratorSetting; import org.apache.accumulo.proxy.thrift.Key; public static IteratorSetting iteratorSetting2ProxyIteratorSetting(org.apache.accumulo.core.client.IteratorSetting is) { return new IteratorSetting(is.getPriority(), is.getName(), is.getIteratorClass(), is.getOptions()); public static Key toThrift(org.apache.accumulo.core.data.Key key) { Key pkey = new Key(ByteBuffer.wrap(key.getRow().getBytes()), ByteBuffer.wrap(key.getColumnFamily().getBytes()), ByteBuffer.wrap(key.getColumnQualifier() public static org.apache.accumulo.core.data.Key fromThrift(Key pkey) { return new org.apache.accumulo.core.data.Key(deNullify(pkey.getRow()), deNullify(pkey.getColFamily()), deNullify(pkey.getColQualifier()), deNullify(pkey.getColVisibility()),
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.thrift.TCredentials; private TCredentials credentials; public void init(FileSystem fs, Instance instance, TCredentials credentials, boolean noTrash) throws IOException { public GCStatus getStatus(TInfo info, TCredentials credentials) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (ratio <= 0. || ratio >= 1.0) throw new IllegalArgumentException("ratio must be > 0. and < 1.0");
Remove this call to "exit" or ensure it is really required.
* @return true if the attempt was successful, false otherwise * @deprecated since 1.4 * @return a MapFile writer
Either log or rethrow this exception.
package org.apache.accumulo.test.continuous;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
import org.apache.accumulo.server.fs.FileRef; import org.apache.accumulo.server.fs.VolumeManager; thread = null;
1 duplicated blocks of code must be removed.
List<Text> range = ConcurrentFixture.generateRange(rand); conn.tableOperations().merge(tableName, range.get(0), range.get(1)); log.debug("merged " + tableName + " from " + range.get(0) + " to " + range.get(1)); log.debug("merge " + tableName + " from " + range.get(0) + " to " + range.get(1) + " failed, table is not online"); log.debug("merge " + tableName + " from " + range.get(0) + " to " + range.get(1) + " failed, doesnt exist");
Define a constant instead of duplicating this literal " from " 3 times.
} else sysPerm = SystemPermission.valueOf(perm); if (hasPerm != conn.securityOperations().hasSystemPermission(targetUser, sysPerm)) throw new AccumuloException("Test framework and accumulo are out of sync!"); if (hasPerm) action = "take"; else action = "give"; if (sysPerm.equals(SystemPermission.GRANT)) return; if (sysPerm.equals(SystemPermission.GRANT)) return;
Remove this call to "exit" or ensure it is really required.
ServerConfiguration conf = new ServerConfiguration(instance); List<TabletStats> onlineTabletsForTable = ThriftUtil.getTServerClient(args[0], conf.getConfiguration()).getTabletStats(null,
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.server.security.SystemCredentials; import org.apache.accumulo.trace.instrument.Tracer; List<TabletStats> onlineTabletsForTable = client.getTabletStats(Tracer.traceInfo(), SystemCredentials.get().getAsThrift(), tableId);
Move this constructor to comply with Java Code Conventions.
public void init(ServerConfiguration conf) { super.init(conf); }
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. */
Replace all tab characters in this file by sequences of white-spaces.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.core.Constants; scanState.authorizations.getAuthorizationsBB(), waitForWrites, scanState.isolated, scanState.readaheadThreshold); long readaheadThreshold; this(instance, credentials, tableId, authorizations, range, fetchedColumns, size, serverSideIteratorList, serverSideIteratorOptions, isolated, Constants.SCANNER_DEFAULT_READAHEAD_THRESHOLD); } 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, long readaheadThreshold) { this.readaheadThreshold = readaheadThreshold; scanState.authorizations.getAuthorizationsBB(), waitForWrites, scanState.isolated, scanState.readaheadThreshold);
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.iterators.user.RegExFilter; IteratorSetting regex = new IteratorSetting(50, "regex", RegExFilter.class); RegExFilter.setRegexs(regex, null, null, regexString, null, false);
Define a constant instead of duplicating this literal "org.apache.accumulo.core.iterators.WholeRowIterator" 4 times.
private static final Logger log = Logger.getLogger(CleanZookeeper.class); /** * @param args * should contain one element: the address of a zookeeper node * @throws IOException * error connecting to accumulo or zookeeper */ public static void main(String[] args) throws IOException { if (args.length < 1) { System.err.println("Usage: " + CleanZookeeper.class.getName() + " hostname[:port]"); System.exit(1); } String root = Constants.ZROOT; ZooReaderWriter zk = ZooReaderWriter.getInstance(); try { for (String child : zk.getChildren(root)) { if (Constants.ZINSTANCES.equals("/" + child)) { for (String instanceName : zk.getChildren(root + Constants.ZINSTANCES)) { String instanceNamePath = root + Constants.ZINSTANCES + "/" + instanceName; byte[] id = zk.getData(instanceNamePath, null); if (id != null && !new String(id).equals(HdfsZooInstance.getInstance().getInstanceID())) { try { zk.recursiveDelete(instanceNamePath, NodeMissingPolicy.SKIP); } catch (KeeperException.NoAuthException ex) { log.warn("Unable to delete " + instanceNamePath); } } } else if (!child.equals(HdfsZooInstance.getInstance().getInstanceID())) { String path = root + "/" + child; try { zk.recursiveDelete(path, NodeMissingPolicy.SKIP); } catch (KeeperException.NoAuthException ex) { log.warn("Unable to delete " + path); } } } catch (Exception ex) { System.out.println("Error Occurred: " + ex); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.thrift.tokens.SecurityToken; public FileDataQuery(String instanceName, String zooKeepers, String user, SecurityToken token, String tableName, Authorizations auths) throws AccumuloException, conn = instance.getConnector(user, token);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
MergeState newState = stats.nextMergeState(connector, state); // now we should be ready to merge but, we have an inconsistent !METADATA table Assert.assertEquals(MergeState.WAITING_FOR_OFFLINE, stats.nextMergeState(connector, state)); Assert.assertEquals(MergeState.WAITING_FOR_CHOPPED, stats.nextMergeState(connector, state)); Assert.assertEquals(MergeState.WAITING_FOR_OFFLINE, stats.nextMergeState(connector, state)); Assert.assertEquals(MergeState.MERGING, stats.nextMergeState(connector, state));
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.
long sleepTime = 2*1000; sleepTime = Math.min(sleepTime*2, 60*1000); UtilWaitThread.sleep(sleepTime); int retries = acuConf.getCount(Property.TSERV_BULK_RETRY); if (entry.getValue() > retries && assignmentFailures.get(entry.getKey()) != null) { log.error("Map file " + entry.getKey() + " failed more than " + retries + " times, giving up.");
Cast one of the operands of this multiplication operation to a "long".
import org.apache.accumulo.core.security.tokens.AccumuloToken; MetadataTable.getEntries(conn.getInstance(), new InstanceTokenWrapper(opts.getWrappedToken().toThrift()), tableName, false, locations, tablets); checkTabletServer(conf.getConfiguration(), opts.getAccumuloToken(), entry, failures); private static void checkTabletServer(AccumuloConfiguration conf, final AccumuloToken<?,?> token, Entry<String,List<KeyExtent>> entry, InstanceTokenWrapper st = new InstanceTokenWrapper(token, HdfsZooInstance.getInstance().getInstanceID());
Return empty string instead.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); final byte[] inputBytes = input.getBytes(utf8);
Move this variable to comply with Java Code Conventions.
String zCancelID = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID() + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_COMPACT_CANCEL_ID; IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance(); if (Long.parseLong(new String(zoo.getData(zCancelID, null))) >= compactId) { // compaction was canceled throw new ThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.OTHER, "Compaction canceled"); }
Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-z0-9]*)*$'.
List<String> fail = client.bulkImportFiles(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), tid, tableId, attempt, errorDir, setTime);
Immediately return this expression instead of assigning it to the temporary variable "ret".
import org.apache.accumulo.server.cli.ClientOpts; @Parameter(description = "<logfile> { <logfile> ...}") AccumuloOutputFormat.setZooKeeperInstance(job, opts.instance, opts.zookeepers); AccumuloOutputFormat.setOutputInfo(job, opts.user, opts.getPassword(), false, null);
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.proxy.Proxy;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@Override public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) { throw new UnsupportedOperationException(); } @Override public Key getTopKey() { return null; } @Override public Value getTopValue() { return null; } @Override public boolean hasTop() { return false; } @Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { } @Override public void next() throws IOException { throw new UnsupportedOperationException(); } @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.client.BatchWriterConfig; BatchWriter w = c.createBatchWriter(tableName, new BatchWriterConfig());
Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.
@Override @Parameter(names = "--rowRegex") @Parameter(names = "--columnFamilyRegex") @Parameter(names = "--columnQualifierRegex") @Parameter(names = "--valueRegex") @Parameter(names = "--output", required = true) @Override AccumuloInputFormat.addIterator(job, regex);
Return empty string instead.
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.core.client.lexicoder; /** * */ public interface Encoder<T> extends org.apache.accumulo.core.iterators.TypedValueCombiner.Encoder<T> { }
Rename this generic name to match the regular expression '^[A-Z]$'.
/* * 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.
m = new Mutation(new Text("0;foo")); m.put(Constants.METADATA_BULKFILE_COLUMN_FAMILY, new Text("/someFile"), new Value("12345".getBytes())); violations = mc.check(null, m); assertNotNull(violations); assertEquals(1, violations.size()); assertEquals(Short.valueOf((short)8), violations.get(0));
Either log or rethrow this exception.
TableSetup ts = new TableSetup("test_ingest", config, TestIngest.getSplitPoints(0, NUM_TO_INGEST, NUM_TABLETS));
Remove this call to "exit" or ensure it is really required.