Diff
stringlengths
10
2k
Message
stringlengths
28
159
package org.apache.accumulo.core.security; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public enum SystemPermission { // One can add new permissions, with new numbers, but please don't change or use numbers previously assigned GRANT((byte)0), CREATE_TABLE((byte)1), DROP_TABLE((byte)2), ALTER_TABLE((byte)3), CREATE_USER((byte)4), DROP_USER((byte)5), ALTER_USER((byte)6), SYSTEM((byte)7); private byte permID; private static HashMap<Byte, SystemPermission> mapping; static { mapping = new HashMap<Byte, SystemPermission>(SystemPermission.values().length); for (SystemPermission perm : SystemPermission.values()) mapping.put(perm.permID, perm); } private SystemPermission(byte id) { this.permID = id; } public byte getId() { return this.permID; } public static List<String> printableValues() { SystemPermission[] a = SystemPermission.values(); List<String> list = new ArrayList<String>(a.length); for (SystemPermission p : a) list.add("System." + p); return list; } public static SystemPermission getPermissionById(byte id) { if (mapping.containsKey(id)) return mapping.get(id); throw new IndexOutOfBoundsException("No such permission"); } }
Return empty string instead.
public String putEphemeralData(String zPath, byte[] data) throws KeeperException, InterruptedException;
Reduce this switch case number of lines from 11 to at most 5, for example by extracting code into methods.
// look for hints of a failure on the previous tablet server if (!logEntries.isEmpty() || needsMajorCompaction(MajorCompactionReason.NORMAL)) { // look for any temp files hanging around removeOldTemporaryFiles(); }
Return empty string instead.
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.
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
package org.apache.accumulo.core.iterators; import java.io.IOException; import java.util.Collection; import java.util.Map; import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; import org.apache.log4j.Logger; public class DebugIterator extends WrappingIterator { private String prefix; private static final Logger log = Logger.getLogger(DebugIterator.class); public DebugIterator(){} public DebugIterator deepCopy(IteratorEnvironment env) { return new DebugIterator(this, env); } private DebugIterator(DebugIterator other, IteratorEnvironment env) { setSource(other.getSource().deepCopy(env)); prefix = other.prefix; } public DebugIterator(String prefix, SortedKeyValueIterator<Key, Value> source){ this.prefix = prefix; this.setSource(source); } @Override public Key getTopKey() { Key wc = getSource().getTopKey(); log.debug(prefix+" getTopKey() --> "+wc); return wc; } @Override public Value getTopValue() { Value w = getSource().getTopValue(); log.debug(prefix+" getTopValue() --> "+w); return w; } @Override public boolean hasTop() { boolean b = getSource().hasTop(); log.debug(prefix+" hasTop() --> "+b); return b; } @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { log.debug(prefix+" seek("+range+", "+columnFamilies+", "+inclusive+")"); getSource().seek(range, columnFamilies, inclusive); } @Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); } }
Return empty string instead.
return new Value(org.apache.accumulo.core.util.AddressUtil.toString(getLocation()).getBytes());
Remove this unused method parameter "ex".
import org.apache.accumulo.core.client.BatchWriterConfig; BatchWriter bw = c.createBatchWriter("testtable1", new BatchWriterConfig());
Remove this unused method parameter "e".
import org.apache.accumulo.core.security.Credentials; public abstract TabletLocation locateTablet(Credentials credentials, Text row, boolean skipRow, boolean retry) throws AccumuloException, public abstract <T extends Mutation> void binMutations(Credentials credentials, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures) throws AccumuloException, AccumuloSecurityException, TableNotFoundException; public abstract List<Range> binRanges(Credentials credentials, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges)
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
* Autogenerated by Thrift Compiler (0.9.0) import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; // check for sub-struct validity if (key != null) { key.validate(); }
Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.
package org.apache.accumulo.examples.wikisearch.util;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
conn.securityOperations().createUser(userName, new PasswordToken(userName + "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. */
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 org.apache.accumulo.core.client.BatchWriterConfig; BatchWriter bw = c.createBatchWriter("testtable", new BatchWriterConfig()); BatchWriter bw = c.createBatchWriter("testtable2", new BatchWriterConfig());
Remove this unused method parameter "e".
private static final int concurrentScans = Monitor.getSystemConfiguration().getCount(Property.TSERV_READ_AHEAD_MAXCONCURRENT);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ private Option userOpt; @Override public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException { String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami()); shellState.getReader().printString(shellState.getConnector().securityOperations().getUserAuthorizations(user) + "\n"); return 0; } @Override public String description() { return "displays the maximum scan authorizations for a user"; } @Override public Options getOptions() { Options o = new Options(); userOpt = new Option(Shell.userOption, "user", true, "user to operate on"); userOpt.setArgName("user"); o.addOption(userOpt); return o; } @Override public int numArgs() { return 0; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* @deprecated since 1.4, MapFiles will no longer be written. Instead use {@link org.apache.accumulo.core.file.rfile.RFileOperations#openWriter}. * @see org.apache.hadoop.io.MapFile.Writer
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. */ package org.apache.accumulo.core.client.security.tokens; import javax.security.auth.Destroyable; import org.apache.hadoop.io.Writable; public interface AuthenticationToken extends Writable, Destroyable, Cloneable { public AuthenticationToken clone(); }
Move this constructor to comply with Java Code Conventions.
* <li>{@link AccumuloInputFormat#setTableQueryConfigs(Job, org.apache.accumulo.core.conf.TableQueryConfig...)}
Either log or rethrow this exception.
import org.apache.accumulo.core.metadata.RootTable;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.util.Properties; if (count % 1000 == 0) makingProgress();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
AccumuloInputFormat.setZooKeeperInstance(job.getConfiguration(), args[0], args[1]); AccumuloInputFormat.setInputInfo(job.getConfiguration(), args[2], args[3].getBytes(), args[4], new Authorizations()); AccumuloInputFormat.fetchColumns(job.getConfiguration(), Collections.singleton(new Pair<Text,Text>(cf, cq)));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
iter.init(source, is.getOptions(), env); iter.init(source, is.getOptions(), env); iter.init(mi, is.getOptions(), env); iter.init(source, is.getOptions(), env);
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
import org.apache.accumulo.examples.wikisearch.ingest.WikipediaInputFormat; import org.apache.accumulo.examples.wikisearch.ingest.WikipediaInputFormat.WikipediaInputSplit; conf.set(WikipediaConfiguration.NUM_GROUPS, "1"); WikipediaInputSplit split = new WikipediaInputSplit(new FileSplit(tmpFile, 0, fs.pathToFile(tmpFile).length(), null),0);
Move this variable to comply with Java Code Conventions.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public long isReady(long tid, Master environment) throws Exception { return 0; } // TODO move this code to isReady() and drop while loop? for (TabletStateStore store : new TabletStateStore[] {zooTabletStateStore, theRest}) { log.info("Requesting " + tabletState.current + " flush tablet " + tabletState.extent + " because it has a log entry " + logEntry); if (zooTabletStateStore != null && !flushed) break; public void undo(long tid, Master m) throws Exception {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * Implementations of BatchDeleter support efficient deletion of ranges in accumulo. * */ * Allows deleting multiple ranges efficiently.
Complete the task associated to this TODO comment.
private final Scanner scanner;
Move this variable to comply with Java Code Conventions.
AccumuloInputFormat.setInputInfo(job.getConfiguration(), args[0], args[1].getBytes(), args[2], new Authorizations()); AccumuloInputFormat.setZooKeeperInstance(job.getConfiguration(), args[3], args[4]);
Remove this unused private "debugQuery" method.
package org.apache.accumulo.server.master.tableOps; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.server.fate.Repo; import org.apache.accumulo.server.master.Master; import org.apache.accumulo.server.master.state.tables.TableManager; import org.apache.log4j.Logger; public class ChangeTableState extends MasterRepo { private static final long serialVersionUID = 1L; private String tableId; private TableOperation top; public ChangeTableState(String tableId, TableOperation top){ this.tableId = tableId; this.top = top; if(top != TableOperation.ONLINE && top != TableOperation.OFFLINE) throw new IllegalArgumentException(top.toString()); } @Override public long isReady(long tid, Master environment) throws Exception { //reserve the table so that this op does not run concurrently with create, clone, or delete table return Utils.reserveTable(tableId, tid, true, true, top); } @Override public Repo<Master> call(long tid, Master env) throws Exception { TableState ts = TableState.ONLINE; if(top == TableOperation.OFFLINE) ts = TableState.OFFLINE; TableManager.getInstance().transitionTableState(tableId, ts); Utils.unreserveTable(tableId, tid, true); Logger.getLogger(ChangeTableState.class).debug("Changed table state "+tableId+" "+ts); env.getEventCoordinator().event("Set table state of %s to %s", tableId, ts); return null; } @Override public void undo(long tid, Master env) throws Exception { Utils.unreserveTable(tableId, tid, true); } }
Return empty string instead.
package org.apache.accumulo.server.test.randomwalk.unit; import java.util.Properties; import org.apache.accumulo.server.test.randomwalk.State; import org.apache.accumulo.server.test.randomwalk.Test; public class Verify extends Test { @Override public void visit(State state, Properties props) throws Exception {} }
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.core.util.shell.Token;
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.Properties; import java.util.Random; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.server.test.randomwalk.State; import org.apache.accumulo.server.test.randomwalk.Test; public class RenameTable 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 srcTableName = tableNames.get(rand.nextInt(tableNames.size())); String newTableName = tableNames.get(rand.nextInt(tableNames.size())); try { conn.tableOperations().rename(srcTableName, newTableName); log.debug("Renamed table "+srcTableName+" "+newTableName); }catch (TableExistsException e){ log.debug("Rename "+srcTableName+" failed, "+newTableName+" exist"); }catch (TableNotFoundException e) { log.debug("Rename "+srcTableName+" failed, doesnt exist"); } } }
Return empty string instead.
@Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> userNames = (List<String>) state.get("users"); String userName = userNames.get(rand.nextInt(userNames.size())); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); try { if (rand.nextBoolean()) { log.debug("Checking systerm permission " + userName); conn.securityOperations().hasSystemPermission(userName, SystemPermission.values()[rand.nextInt(SystemPermission.values().length)]); } else { log.debug("Checking table permission " + userName + " " + tableName); conn.securityOperations().hasTablePermission(userName, tableName, TablePermission.values()[rand.nextInt(TablePermission.values().length)]); } } catch (AccumuloSecurityException ex) { log.debug("Unable to check permissions: " + ex.getCause()); } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.proxy.thrift.PrincipalToken; protected static PrincipalToken userpass; userpass = new PrincipalToken("root", ByteBuffer.wrap("".getBytes())); tpc.proxy().changePrincipalTokenword(userpass, testuser, ByteBuffer.wrap("newpass".getBytes()));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
Remove this unused private "appendProp" method.
import org.apache.accumulo.server.cli.ClientOpts; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; static class Opts extends ClientOpts { @Parameter(names="-master", description="remove master locks") @Parameter(names="-tserver", description="remove tablet server locks") @Parameter(names="-tracers", description="remove tracer locks") @Parameter(names="-verbose", description="print out messages about progress") boolean verbose = false; } public static void main(String[] args) { Opts opts = new Opts(); opts.parseArgs(ZooZap.class.getName(), args); if (!opts.zapMaster && !opts.zapTservers && !opts.zapTracers) { new JCommander(opts).usage(); String iid = opts.getInstance().getInstanceID(); if (opts.zapMaster) { if (opts.zapTservers) { if (opts.zapMaster) if (opts.zapTracers) {
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. */ * Hadoop partitioner that uses ranges based on row keys, and optionally sub-bins based on hashing. public class KeyRangePartitioner extends Partitioner<Key,Writable> implements Configurable { public int getPartition(Key key, Writable value, int numPartitions) { public Configuration getConf() { public void setConf(Configuration conf) { * Sets the hdfs file name to use, containing a newline separated list of Base64 encoded split points that represent ranges for partitioning public static void setSplitFile(JobContext job, String file) { public static void setNumSubBins(JobContext job, int num) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.util.RootTable; if ((table.equals(MetadataTable.ID) || table.equals(RootTable.ID)) && permission.equals(TablePermission.READ))
Reduce this switch case number of lines from 12 to at most 5, for example by extracting code into methods.
private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(DisconnectLogger.class); private String location; public DisconnectLogger(String location) { this.location = location; } @Override public long isReady(long tid, Master environment) throws Exception { return 0; } @Override public Repo<Master> call(long tid, Master m) throws Exception { // TODO move this to isReady() and drop while loop? Map<String,String> loggers = m.getLoggers(); boolean foundMatch = false; do { // TODO: doesn't work if there are multiple loggers on the same node for (Entry<String,String> entry : loggers.entrySet()) { InetSocketAddress addr = AddressUtil.parseAddress(entry.getValue(), 0); if (addr.getAddress().getHostAddress().equals(location)) { foundMatch = true; MutationLogger.Iface client = ThriftUtil.getClient(new MutationLogger.Client.Factory(), addr, ServerConfiguration.getSystemConfiguration()); try { client.beginShutdown(null, SecurityConstants.getSystemCredentials()); } catch (Exception ex) { log.error("Unable to talk to logger at " + addr); } finally { ThriftUtil.returnClient(client); } String zpath = ZooUtil.getRoot(m.getInstance()) + Constants.ZLOGGERS + "/" + entry.getKey(); ZooReaderWriter.getInstance().recursiveDelete(zpath, NodeMissingPolicy.SKIP); log.info("logger asked to halt " + location); return new FlushTablets(entry.getValue()); } } } while (m.stillMaster() && foundMatch); return null; } @Override public void undo(long tid, Master m) throws Exception {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
+ "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes())));
Remove this unused private "appendProp" method.
import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.admin.TableOperations; import org.apache.accumulo.core.iterators.LongCombiner; import org.apache.accumulo.core.iterators.user.SummingCombiner; TableOperations tableOps = state.getConnector().tableOperations(); if (!tableOps.exists(getTableName())) { tableOps.create(getTableName()); IteratorSetting is = new IteratorSetting(10, org.apache.accumulo.core.iterators.user.SummingCombiner.class); SummingCombiner.setEncodingType(is, LongCombiner.Type.STRING); SummingCombiner.setColumns(is, BulkPlusOne.COLNAMES); tableOps.attachIterator(getTableName(), is);
Remove this unused method parameter "table".
Class<? extends Formatter> formatterClass = getFormatter(); printRecords(scanner, printTimestamps, paginate, formatterClass); } public final void printRecords(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps, boolean paginate, Class<? extends Formatter> formatterClass) throws IOException { * Return the formatter for this table, . public Class<? extends Formatter> getFormatter() { return getFormatter(this.tableName); } public Class<? extends Formatter> getFormatter(String tableName) { Class<? extends Formatter> formatter = FormatterCommand.getCurrentFormatter(tableName, this); if (null == formatter) { log.error("Could not load the specified formatter. Using the DefaultFormatter"); return this.defaultFormatterClass; return formatter;
Either log or rethrow this exception.
protected static class AccumuloRecordWriter extends RecordWriter<Text,Mutation> { protected AccumuloRecordWriter(Configuration conf) throws AccumuloException, AccumuloSecurityException { Level l = getLogLevel(conf); log.setLevel(getLogLevel(conf)); this.simulate = getSimulationMode(conf); this.createTables = canCreateTables(conf); String tname = getDefaultTableName(conf); this.conn = getInstance(conf).getConnector(getUsername(conf), getPassword(conf)); mtbw = conn.createMultiTableBatchWriter(getMaxMutationBufferSize(conf), getMaxLatency(conf), getMaxWriteThreads(conf)); checkOutputSpecs(job.getConfiguration()); } public void checkOutputSpecs(Configuration conf) throws IOException { Connector c = getInstance(conf).getConnector(getUsername(conf), getPassword(conf)); if (!c.securityOperations().authenticateUser(getUsername(conf), getPassword(conf))) return new AccumuloRecordWriter(attempt.getConfiguration());
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. */ * zoo = new ZooKeeper(keepers, 30 * 1000, this); if (zoo.getState().equals(States.CONNECTED)) break; synchronized protected String getSpanKey(Map<String,String> data) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * @deprecated since 1.4, use {@code scan -r <row>} instead. */ Shell.log.warn("selectrow is deprecated, use 'scan -r <row>'"); }
1 duplicated blocks of code must be removed.
pathToRemove = "/" + tableId + pathToRemove;
Introduce a new variable instead of reusing the parameter "pathToRemove".
fs.delete(new Path(base + "/testrf")); fs.mkdirs(new Path(base + "/testBulkFail"));
Make folder a static final constant or non-public and provide accessors if needed.
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
import org.apache.accumulo.trace.instrument.Span; import org.apache.accumulo.trace.instrument.Trace; @Parameter(names = "--authsFile", description = "read the authorities to use from a file") auths = Collections.singletonList(Authorizations.EMPTY); auths = Collections.singletonList(Authorizations.EMPTY);
Remove this unused method parameter "range".
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException { final String user = cl.getArgs()[0]; if (shellState.getConnector().whoami().equals(user)) { } public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
principal = "root";
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.io.File; import org.junit.Rule; import org.junit.rules.TemporaryFolder; @Rule public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target")); FunctionalTestUtils.createRFiles(c, fs, folder.getRoot() + "/testmf", ROWS, SPLITS, 8); FunctionalTestUtils.bulkImport(c, fs, TABLE_NAME, folder.getRoot() + "/testmf");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
* @return A map of Aggregator Table Properties. * @see TableOperations#attachIterator(String, IteratorSetting)
Either log or rethrow this exception.
import java.util.List; map.put(new Key(new Text("r1"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 1l), new Value("val1".getBytes())); map.put(new Key(new Text("r1"), new Text("cf1"), new Text("cq2"), new Text("cv1"), 2l), new Value("val2".getBytes())); map.put(new Key(new Text("r2"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 3l), new Value("val3".getBytes())); map.put(new Key(new Text("r2"), new Text("cf2"), new Text("cq1"), new Text("cv1"), 4l), new Value("val4".getBytes())); map.put(new Key(new Text("r3"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 5l), new Value("val4".getBytes())); map.put(new Key(new Text("r3"), new Text("cf1"), new Text("cq1"), new Text("cv2"), 6l), new Value("val4".getBytes())); map.put(new Key(new Text("r4"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 7l), new Value("".getBytes())); map.put(new Key(new Text("r4"), new Text("cf1"), new Text("cq1"), new Text(""), 8l), new Value("val1".getBytes())); map.put(new Key(new Text("r4"), new Text("cf1"), new Text(""), new Text("cv1"), 9l), new Value("val1".getBytes())); map.put(new Key(new Text("r4"), new Text(""), new Text("cq1"), new Text("cv1"), 10l), new Value("val1".getBytes())); map.put(new Key(new Text(""), new Text("cf1"), new Text("cq1"), new Text("cv1"), 11l), new Value("val1".getBytes()));
Replace all tab characters in this file by sequences of white-spaces.
private Option verboseOpt, forceOpt, sizeOpt; String tableName = OptUtil.getTableOpt(cl, shellState); Text startRow = OptUtil.getStartRow(cl); Text endRow = OptUtil.getEndRow(cl); o.addOption(OptUtil.startRowOpt()); o.addOption(OptUtil.endRowOpt());
Either log or rethrow this exception.
if (!ok) return false; if (!isAlphaNum(mutation.getRow())) violations = addViolation(violations, NON_ALPHA_NUM_ROW); if (!isAlphaNum(columnUpdate.getColumnFamily())) violations = addViolation(violations, NON_ALPHA_NUM_COLF); if (!isAlphaNum(columnUpdate.getColumnQualifier())) violations = addViolation(violations, NON_ALPHA_NUM_COLQ);
Remove this call to "exit" or ensure it is really required.
target = WalkingSecurity.get(state).getTabUserName(); conn = WalkingSecurity.get(state).getSystemConnector(); target = WalkingSecurity.get(state).getSysUserName(); boolean exists = WalkingSecurity.get(state).userExists(target); boolean hasPermission = WalkingSecurity.get(state).canChangeAuthorizations(WalkingSecurity.get(state).getSysAuthInfo(), target); String[] possibleAuths = WalkingSecurity.get(state).getAuthsArray(); WalkingSecurity.get(state).changeAuthorizations(target, auths);
Reduce this switch case number of lines from 44 to at most 5, for example by extracting code into methods.
/** * This class remains here for backwards compatibility. * * @deprecated since 1.4 * @see org.apache.accumulo.core.iterators.user.IntersectingIterator */ public class IntersectingIterator extends org.apache.accumulo.core.iterators.user.IntersectingIterator { }
Remove this unused private "match" method.
import org.apache.accumulo.server.fs.VolumeManager.FileType; private int removeMetadataEntries(Map<Path,String> fileToServerMap, Set<Path> sortedWALogs, GCStatus status) throws IOException, KeeperException, path = fs.getFullPath(FileType.WAL, filename);
Remove this unused private "FileType" constructor.
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; clazz = AccumuloVFSClassLoader.loadClass(classname, Aggregator.class);
Remove this unused private "appendProp" method.
String retValue = ""; retValue = new String(get(), Constants.VALUE_ENCODING); return retValue;
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.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode; import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; import org.apache.accumulo.core.client.security.tokens.PasswordToken;
Move this constructor to comply with Java Code Conventions.
import org.apache.accumulo.core.security.tokens.AuthenticationToken; * <li>{@link AccumuloRowInputFormat#setConnectorInfo(JobConf, String, AuthenticationToken)} OR {@link AccumuloRowInputFormat#setConnectorInfo(JobConf, Path)}
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.security.tokens.AuthenticationToken; import org.apache.accumulo.core.security.tokens.PasswordToken;
1 duplicated blocks of code must be removed.
package org.apache.accumulo.server.master.state; import java.util.Collection; import java.util.Set; public interface CurrentState { Set<String> onlineTables(); Set<TServerInstance> onlineTabletServers(); Collection<MergeInfo> merges(); }
Return empty string instead.
siteConfig.put(Property.MASTER_RECOVERY_DELAY.getKey(), "1s"); siteConfig.put(Property.INSTANCE_ZK_TIMEOUT.getKey(), "1s"); cfg.setSiteConfig(siteConfig); @Test(timeout = 10 * 60 * 1000)
Replace this use of System.out or System.err by a logger.
package org.apache.accumulo.examples.simple.mapreduce;
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.fate.util; public class Daemon extends Thread { public Daemon() { setDaemon(true); } public Daemon(Runnable target) { super(target); setDaemon(true); } public Daemon(String name) { super(name); setDaemon(true); } public Daemon(ThreadGroup group, Runnable target) { super(group, target); setDaemon(true); } public Daemon(ThreadGroup group, String name) { super(group, name); setDaemon(true); } public Daemon(Runnable target, String name) { super(target, name); setDaemon(true); } public Daemon(ThreadGroup group, Runnable target, String name) { super(group, target, name); setDaemon(true); } public Daemon(ThreadGroup group, Runnable target, String name, long stackSize) { super(group, target, name, stackSize); setDaemon(true); } }
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.AuthenticationTokenSerializer; import org.apache.accumulo.core.security.Credentials; * @param context * @see #setConnectorInfo(Job, String, AuthenticationToken) Connector conn = instance.getConnector(principal, AuthenticationTokenSerializer.deserialize(tokenClass, token)); scanner = new OfflineScanner(instance, new Credentials(principal, AuthenticationTokenSerializer.deserialize(tokenClass, token)), Tables.getTableId( Connector conn = instance.getConnector(getPrincipal(context), AuthenticationTokenSerializer.deserialize(getTokenClass(context), getToken(context))); while (!tl.binRanges(new Credentials(getPrincipal(context), AuthenticationTokenSerializer.deserialize(getTokenClass(context), getToken(context))), ranges, binnedRanges).isEmpty()) {
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
* @deprecated since 1.4 * @use org.apache.accumulo.core.iterators.Combiner
1 duplicated blocks of code must be removed.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @SuppressWarnings("all") public class TableExistsException extends TException implements org.apache.thrift.TBase<TableExistsException, TableExistsException._Fields>, java.io.Serializable, Cloneable { @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.server.master.state; public enum MergeState { /** * Not merging */ NONE, /** * created, stored in zookeeper, other merges are prevented on the table */ STARTED, /** * put all matching tablets online, split tablets if we are deleting */ SPLITTING, /** * after the tablet server chops the file, it marks the metadata table with a chopped marker */ WAITING_FOR_CHOPPED, /** * when the number of chopped tablets in the range matches the number of online tablets in the range, * take the tablets offline */ WAITING_FOR_OFFLINE, /** * when the number of chopped, offline tablets equals the number of merge tablets, begin the metadata updates */ MERGING, /** * merge is complete, the resulting tablet can be brought online, * remove the marker in zookeeper */ COMPLETE; }
Return empty string instead.
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.
/* * 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.
job.setNumReduceTasks(0);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
Move this constructor to comply with Java Code Conventions.
import org.apache.accumulo.core.client.impl.thrift.ClientService.Iface; import org.apache.accumulo.core.util.Pair; String server = null; Pair<String,Iface> pair = ServerClient.getConnection(instance); server = pair.getFirst(); client = pair.getSecond(); log.debug("ClientService request failed " + server + ", retrying ... ", tte); String server = null; Pair<String,Iface> pair = ServerClient.getConnection(instance); server = pair.getFirst(); client = pair.getSecond(); log.debug("ClientService request failed " + server + ", retrying ... ", tte); public static Pair<String,ClientService.Iface> getConnection(Instance instance) throws TTransportException { Pair<String,TTransport> pair = ThriftTransportPool.getInstance().getAnyTransport(servers); ClientService.Iface client = ThriftUtil.createClient(new ClientService.Client.Factory(), pair.getSecond()); return new Pair<String,ClientService.Iface>(pair.getFirst(), client);
The Cyclomatic Complexity of this method "call" is 13 which is greater than 10 authorized.
public static class VisualizationConfig { boolean useCircles = true; StatType motion = StatType.allmax; StatType color = StatType.allavg; int spacing = 40; String url; } String url = urlsb.toString(); VisualizationConfig cfg = new VisualizationConfig(); cfg.useCircles = false; cfg.motion = StatType.valueOf(s); cfg.color = StatType.valueOf(s); cfg.spacing = 10; cfg.spacing = 20; cfg.spacing = 80; int width = (int) Math.ceil(Math.sqrt(tservers.size())) * cfg.spacing; int height = (int) Math.ceil(tservers.size() / width) * cfg.spacing; doSettings(sb, cfg, width < 640 ? 640 : width, height < 640 ? 640 : height); doScript(sb, cfg, tservers); private void doSettings(StringBuilder sb, VisualizationConfig cfg, int width, int height) { .append(!cfg.useCircles ? " selected='true'" : "").append(">Squares</option></select></span>\n"); sb.append("&nbsp;&nbsp<span class='viscontrol'>Size: <select id='size' onchange='setSize(this)'><option").append(cfg.spacing == 10 ? " selected='true'" : "") .append(">10</option><option").append(cfg.spacing == 20 ? " selected='true'" : "").append(">20</option><option") .append(cfg.spacing == 40 ? " selected='true'" : "").append(">40</option><option").append(cfg.spacing == 80 ? " selected='true'" : "") addOptions(sb, cfg.motion); addOptions(sb, cfg.color); private void doScript(StringBuilder sb, VisualizationConfig cfg, ArrayList<TabletServerStatus> tservers) { sb.append("var jsonurl = '" + cfg.url + "json';\n"); sb.append("var visurl = '" + cfg.url + "vis';\n"); sb.append("var serverurl = '" + cfg.url + "tservers?s=';\n\n");
Remove this unused method parameter "tservers".
if (start != null && end != null) if (start.compareTo(end) >= 0) throw new ThriftTableOperationException(tableId, null, TableOperation.MERGE, TableOperationExceptionType.BAD_RANGE, "start row must be less than end row"); if (mergeInfo.getState() != MergeState.NONE) log.warn("removing merge information " + mergeInfo);
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; import org.apache.accumulo.fate.zookeeper.ZooReaderWriter.Mutator;
Remove this call to "exit" or ensure it is really required.
private static final long serialVersionUID = 1L; V dfault; public DefaultMap(V dfault) { this.dfault = dfault; } @SuppressWarnings("unchecked") @Override public V get(Object key) { V result = super.get(key); if (result == null) { try { super.put((K) key, result = construct()); } catch (Exception ex) { throw new RuntimeException(ex); } return result; } @SuppressWarnings("unchecked") private V construct() { try { return (V) dfault.getClass().newInstance(); } catch (Exception ex) { return dfault; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.thrift.transport.TTransport; public TabletServerStatus getTableMap(boolean usePooledConnection) throws TException, ThriftSecurityException { if (usePooledConnection == true) throw new UnsupportedOperationException(); TTransport transport = ThriftUtil.createTransport(address, conf); TabletClientService.Client client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport); if (transport != null) transport.close();
Remove the literal "true" boolean value.
* @deprecated since 1.4 * @use org.apache.accumulo.core.iterators.Combiner
Either log or rethrow this exception.
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.SummingCombiner} with * {@link org.apache.accumulo.core.iterators.LongCombiner.Type#FIXEDLEN}
Either log or rethrow this exception.
import java.util.HashMap; import java.util.Set; import java.util.Map.Entry; import org.apache.accumulo.core.security.thrift.SecurityErrorCode; HashMap<String,Set<SecurityErrorCode>> tables = new HashMap<String,Set<SecurityErrorCode>>(); for (Entry<KeyExtent,Set<SecurityErrorCode>> ke : e.getAuthorizationFailures().entrySet()) { Set<SecurityErrorCode> secCodes = tables.get(ke.getKey().getTableId().toString()); if (secCodes == null) { secCodes = new HashSet<SecurityErrorCode>(); tables.put(ke.getKey().getTableId().toString(), secCodes); } secCodes.addAll(ke.getValue());
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.util.PeekingIterator;
Either log or rethrow this exception.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
296 duplicated blocks of code must be removed.
import org.apache.accumulo.server.security.SystemCredentials; AuditedSecurityOperation.getInstance(iid, true).initializeSecurity(SystemCredentials.get().getAsThrift(), DEFAULT_ROOT_USER, opts.rootpass);
Move this constructor to comply with Java Code Conventions.
shell.config("--fake", "-p", "pass");
This block of commented-out lines of code should be removed.
import org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator; ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter); ColumnQualifierFilter colFilter = new ColumnQualifierFilter(cfsi, new HashSet<Column>(options.fetchedColumns));
Use "Integer.toString" instead.
public static void alter(State state, Properties props) throws Exception {
Replace all tab characters in this file by sequences of white-spaces.
public Key key; public byte[] value; public KeyValue(Key key, byte[] value) { this.key = key; this.value = value; } public KeyValue(Key key, ByteBuffer value) { this.key = key; this.value = toBytes(value); } @Override public Key getKey() { return key; } @Override public Value getValue() { return new Value(value); } @Override public Value setValue(Value value) { throw new UnsupportedOperationException(); } public String toString() { return key + " " + new String(value); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.UserPassToken; connector = instance.getConnector(new UserPassToken("user", "password")); Connector connector = instance.getConnector(new UserPassToken("user", "password"));
Either log or rethrow this exception.