Diff
stringlengths
10
2k
Message
stringlengths
28
159
import org.apache.accumulo.core.security.tokens.AccumuloToken; public static synchronized TabletLocator getInstance(Instance instance, AccumuloToken<?,?> credentials, Text tableId) { return getInstance(instance, new InstanceTokenWrapper(credentials, instance.getInstanceID()), tableId); }
Return empty string instead.
import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner); if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.hasColumns(next.getKey())) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
zoo.putPersistentData(path, "forced down".getBytes(), NodeExistsPolicy.OVERWRITE);
Remove this unused method parameter "ex".
import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.server.util.TServerUtils.ServerAddress; ServerAddress sa = TServerUtils.startServer(getSystemConfiguration(), hostname, Property.MASTER_CLIENTPORT, processor, "Master", "Master Client Service Handler", null, Property.MASTER_MINTHREADS, Property.MASTER_THREADCHECK, Property.GENERAL_MAX_MESSAGE_SIZE); clientService = sa.server; String address = AddressUtil.toString(sa.address); log.info("Setting master lock data to " + address); masterLock.replaceLockData(address.getBytes());
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. */ Range range = new Range(Constants.ROOT_TABLET_EXTENT.getMetadataEntry(), false, KeyExtent.getMetadataEntry(new Text(Constants.METADATA_TABLE_ID), null), true);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.fate.Repo;
Remove this call to "exit" or ensure it is really required.
getSource().seek(range, colFamSet, inclusive); getSource().seek(range, colFamSet, inclusive); super.seek(range, colFamSet, inclusive);
Use "Integer.toString" instead.
import org.apache.accumulo.core.conf.AccumuloConfiguration; private final AccumuloConfiguration conf; TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf); public LiveTServerSet(Instance instance, AccumuloConfiguration conf, Listener cback) { this.conf = conf;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.SecurityUtil; import org.apache.accumulo.trace.instrument.CountSampler; import org.apache.accumulo.trace.instrument.Sampler; import org.apache.accumulo.trace.instrument.Span; import org.apache.accumulo.trace.instrument.Trace; import org.apache.accumulo.trace.instrument.thrift.TraceWrap; import org.apache.accumulo.trace.thrift.TInfo; @Override public void unableToMonitorLockNode(final Throwable e) { Halt.halt(-1, new Runnable() { @Override public void run() { log.fatal("No longer able to monitor lock node ", e); } }); }
Remove this call to "exit" or ensure it is really required.
package util; import org.apache.accumulo.core.data.Key; public class KeyParser extends BaseKeyParser { public static final String SELECTOR_FIELD = "selector"; public static final String DATATYPE_FIELD = "dataType"; public static final String FIELDNAME_FIELD = "fieldName"; public static final String UID_FIELD = "uid"; public static final String DELIMITER = "\0"; @Override public void parse(Key key) { super.parse (key); String[] colFamParts = this.keyFields.get(BaseKeyParser.COLUMN_FAMILY_FIELD).split(DELIMITER); this.keyFields.put(FIELDNAME_FIELD, colFamParts.length >= 2 ? colFamParts[1] : ""); String[] colQualParts = this.keyFields.get(BaseKeyParser.COLUMN_QUALIFIER_FIELD).split(DELIMITER); this.keyFields.put(SELECTOR_FIELD, colQualParts.length >= 1 ? colQualParts[0] : ""); this.keyFields.put(DATATYPE_FIELD, colQualParts.length >= 2 ? colQualParts[1] : ""); this.keyFields.put(UID_FIELD, colQualParts.length >= 3 ? colQualParts[2] : ""); } @Override public BaseKeyParser duplicate () { return new KeyParser(); } public String getSelector() { return keyFields.get(SELECTOR_FIELD); } public String getDataType() { return keyFields.get(DATATYPE_FIELD); } public String getFieldName () { return keyFields.get(FIELDNAME_FIELD); } public String getUid() { return keyFields.get(UID_FIELD); } public String getDataTypeUid() { return getDataType()+DELIMITER+getUid(); } // An alias for getSelector public String getFieldValue() { return getSelector(); } }
Return empty string instead.
@SuppressWarnings("all") public class GCStatus implements org.apache.thrift.TBase<GCStatus, GCStatus._Fields>, java.io.Serializable, Cloneable {
13 duplicated blocks of code must be removed.
log.info("Instance " + config.getInstance().getInstanceID());
Define a constant instead of duplicating this literal " for table " 4 times.
private SortedKeyValueIterator<Key,Value> source; private Key key; private Value value; @Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { this.source = source; } @Override public boolean hasTop() { return key != null; } @Override public void next() throws IOException { if (source.hasTop()) { ByteSequence currentRow = source.getTopKey().getRowData(); ByteSequence currentColf = source.getTopKey().getColumnFamilyData(); long ts = source.getTopKey().getTimestamp(); source.next(); int count = 1; while (source.hasTop() && source.getTopKey().getRowData().equals(currentRow) && source.getTopKey().getColumnFamilyData().equals(currentColf)) { count++; source.next(); } this.key = new Key(currentRow.toArray(), currentColf.toArray(), new byte[0], new byte[0], ts); this.value = new Value(Integer.toString(count).getBytes()); } else { this.key = null; this.value = null; } @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { source.seek(range, columnFamilies, inclusive); next(); } @Override public Key getTopKey() { return key; } @Override public Value getTopValue() { return value; } @Override public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) { // TODO Auto-generated method stub return null; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.server.conf.ServerConfiguration; /** * Initialize the memory manager. * * @param conf */ void init(ServerConfiguration conf);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.server.test.continuous.ContinuousWalk.RandomAuths; private static String authsFile = null; } else if (args[i].equals("--auths")) { authsFile = args[++i]; + " [--debug <debug log>] [--auths <file>] <instance name> <zookeepers> <user> <pass> <table> <min> <max> <sleep time> <num to scan>"); Random r = new Random(); RandomAuths randomAuths = new RandomAuths(authsFile); Authorizations auths = randomAuths.getAuths(r); Scanner scanner = conn.createScanner(table, auths);
Remove this unused method parameter "r".
public class RenameIT extends SimpleMacIT { String name1 = makeTableName(); String name2 = makeTableName(); opts.tableName = name1; c.tableOperations().rename(name1, name2); vopts.tableName = name2; c.tableOperations().delete(name1); c.tableOperations().rename(name2, name1); vopts.tableName = name1;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.cloudtrace.instrument.receivers;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * indicates a variable-length encoding of a list of Longs using {@link SummingArrayCombiner.VarLongArrayEncoder} */ VARLEN, /** * indicates a fixed-length (8 bytes for each Long) encoding of a list of Longs using {@link SummingArrayCombiner.FixedLongArrayEncoder} */ FIXEDLEN, /** * indicates a string (comma-separated) representation of a list of Longs using {@link SummingArrayCombiner.StringArrayEncoder} */ STRING
Do not forget to remove this deprecated code someday.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Autogenerated by Thrift Compiler (0.9.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package org.apache.accumulo.core.data.thrift; import java.util.Map; import java.util.HashMap; import org.apache.thrift.TEnum; @SuppressWarnings("all") public enum TCMStatus implements org.apache.thrift.TEnum { ACCEPTED(0), REJECTED(1), VIOLATED(2), IGNORED(3); private final int value; private TCMStatus(int value) { this.value = value; } /** * Get the integer value of this enum value, as defined in the Thrift IDL. */ public int getValue() { return value; } /** * Find a the enum type by its integer value, as defined in the Thrift IDL. * @return null if the value is not found. */ public static TCMStatus findByValue(int value) { switch (value) { case 0: return ACCEPTED; case 1: return REJECTED; case 2: return VIOLATED; case 3: return IGNORED; default: return null; } } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.trace.instrument.Tracer;
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import java.io.File; static TemporaryFolder tempFolder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.server.mini;
This block of commented-out lines of code should be removed.
tpc.proxy().update(writer, mutations); tpc.proxy().closeWriter(writer); String cookie = tpc.proxy().createScanner(userpass, testTable, null); ScanResult kvList = tpc.proxy().nextK(cookie, k);
Either log or rethrow this exception.
AccumuloApp.run(accumulo.getInstanceName(), accumulo.getZooKeepers(), "superSecret", new String[0]);
Define a constant instead of duplicating this literal "digest" 13 times.
import org.apache.accumulo.core.util.shell.ShellOptionsJC; protected void setInstance(ShellOptionsJC options) { java.util.Scanner scanner = new java.util.Scanner(execFile);
Either log or rethrow this exception.
import java.util.concurrent.TimeUnit; this.timeOut = scanner.getTimeout(TimeUnit.MILLISECONDS); smi.scanner.setTimeout(timeOut, TimeUnit.MILLISECONDS); public void setTimeOut(int timeOut) { if (timeOut == Integer.MAX_VALUE) setTimeout(Long.MAX_VALUE, TimeUnit.MILLISECONDS); else setTimeout(timeOut, TimeUnit.SECONDS); long timeout = getTimeout(TimeUnit.SECONDS); if (timeout >= Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int) timeout;
Move this constructor to comply with Java Code Conventions.
addScanIterators(shellState, cl, scanner, tableName);
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
package org.apache.accumulo.wikisearch.iterator; import org.apache.accumulo.wikisearch.function.QueryFunctions; import org.apache.accumulo.wikisearch.util.FieldIndexKeyParser;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.minicluster;
Either log or rethrow this exception.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(utf8),
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.core.util.AddressUtil;
2 duplicated blocks of code must be removed.
@Test(timeout = 4 * 60 * 1000)
Replace this use of System.out or System.err by a logger.
conn.tableOperations().listSplits(t);
Either log or rethrow this exception.
if (s.length() >= width) return s;
Remove this call to "exit" or ensure it is really required.
if (failures != null && failures.length > 0) { throw new Exception(failures.length + " failure files found importing files from " + dir); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.client.Instance; private Instance instance = null; TableConfWatcher(Instance instance) { this.instance = instance; String tablesPrefix = ZooUtil.getRoot(instance) + Constants.ZTABLES + "/"; ServerConfiguration.getTableConfiguration(instance, tableId).propertyChanged(key); ServerConfiguration.getTableConfiguration(instance, tableId).propertiesChanged(key);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.examples.filedata; import java.util.ArrayList; import org.apache.hadoop.io.Text; public class KeyUtil { public static final byte[] nullbyte = new byte[]{0}; public static Text buildNullSepText(String... s) { Text t = new Text(s[0]); for (int i = 1; i < s.length; i++) { t.append(nullbyte, 0, 1); t.append(s[i].getBytes(), 0, s[i].length()); } return t; } public static String[] splitNullSepText(Text t) { ArrayList<String> s = new ArrayList<String>(); byte[] b = t.getBytes(); int lastindex = 0; for (int i = 0; i < t.getLength(); i++) { if (b[i]==(byte)0) { s.add(new String(b,lastindex,i-lastindex)); lastindex = i+1; } } s.add(new String(b,lastindex,t.getLength()-lastindex)); return s.toArray(new String[s.size()]); } }
Return empty string instead.
import org.apache.accumulo.core.util.shell.commands.PingCommand; Command[] debuggingCommands = {new ClasspathCommand(), new DebugCommand(), new ListScansCommand(), new ListCompactionsCommand(), new TraceCommand(), new PingCommand()};
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. */ String etcetera = null; if (!parser.matches()) throw new IllegalArgumentException("Unable to parse: " + everything + " as a version"); if (parser.group(1) != null) package_ = parser.group(2); if (parser.group(5) != null) minor = Integer.valueOf(parser.group(5)); if (parser.group(7) != null) release = Integer.valueOf(parser.group(7)); if (parser.group(9) != null) etcetera = parser.group(9); public String getPackage() { return package_; } public int getMajorVersion() { return major; } public int getMinorVersion() { return minor; } public int getReleaseVersion() { return release; } public String getEtcetera() { return etcetera; } public String toString() {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (Tables.getTableState(instance, tableId) == TableState.OFFLINE) throw new TableOfflineException(instance, tableId); if (tableops == null) tableops = new TableOperationsImpl(instance, credentials); if (secops == null) secops = new SecurityOperationsImpl(instance, credentials); if (instanceops == null) instanceops = new InstanceOperations(instance, credentials);
Remove this call to "exit" or ensure it is really required.
package org.apache.accumulo.examples.wikisearch.parser; import org.apache.accumulo.examples.wikisearch.parser.QueryParser.QueryTerm;
Rename "table" which hides the field declared at line 107.
@Test(timeout = 2 * 60 * 1000) String tableName = makeTableName(); c.tableOperations().create(tableName); BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig()); getConnector().tableOperations().flush(tableName, null, null, true); getConnector().tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "4K"); Collection<Text> splits = getConnector().tableOperations().listSplits(tableName); splits = getConnector().tableOperations().listSplits(tableName); BatchScanner bs = getConnector().createBatchScanner(tableName, Authorizations.EMPTY, 4); splits = getConnector().tableOperations().listSplits(tableName);
Either log or rethrow this exception.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
* 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. */ return new KeyExtent(new Text(tableId), endRow == null ? null : new Text(endRow), prevEndRow == null ? null : new Text(prevEndRow));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@Deprecated
Return empty string instead.
return "Metadata Tablets";
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 java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.util.CachedConfiguration; import org.apache.accumulo.minicluster.MiniAccumuloConfig; import org.apache.accumulo.minicluster.ProcessReference; import org.apache.accumulo.minicluster.ServerType; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class CleanTmpIT extends ConfigurableMacIT { @Override public void configure(MiniAccumuloConfig cfg) { Map<String, String> props = new HashMap<String, String>(); props.put(Property.INSTANCE_ZK_TIMEOUT.getKey(), "3s"); cfg.setSiteConfig(props); cfg.setNumTservers(1); cfg.useMiniDFS(true); } @Test(timeout = 4 * 60 * 1000) FileSystem fs = getCluster().getFileSystem(); Path tmp = new Path(getCluster().getConfig().getAccumuloDir().getPath() + "/tables/" + id + "/default_tablet/junk.rf_tmp"); fs.create(tmp).close(); for (ProcessReference tserver: getCluster().getProcesses().get(ServerType.TABLET_SERVER)) { getCluster().killProcess(ServerType.TABLET_SERVER, tserver); } getCluster().start(); Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY); for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) ; assertFalse(!fs.exists(tmp));
Remove this empty statement.
@Override
Either log or rethrow this exception.
appendProp(fileWriter, Property.TRACE_TOKEN_PROPERTY_PREFIX + ".password", config.getRootPassword(), siteConfig);
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
private static final long serialVersionUID = 1L;
Rename this class name 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.
new_.putPersistentData(path, newInstanceId.getBytes(), NodeExistsPolicy.OVERWRITE);
Remove this unused method parameter "ex".
* <li>{@link AccumuloRowInputFormat#setConnectorInfo(Job, String, AuthenticationToken)}
3 duplicated blocks of code must be removed.
if (source == null) throw new IllegalStateException("getting null source"); if (source == null) throw new IllegalStateException("no source set"); if (seenSeek == false) throw new IllegalStateException("never been seeked"); if (source == null) throw new IllegalStateException("no source set"); if (seenSeek == false) throw new IllegalStateException("never been seeked"); if (source == null) throw new IllegalStateException("no source set"); if (seenSeek == false) throw new IllegalStateException("never been seeked"); if (source == null) throw new IllegalStateException("no source set"); if (seenSeek == false) throw new IllegalStateException("never been seeked");
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. */ if (runnable != null) runnable.run();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
nextEvent.event("tablet %s was loaded on %s", tablet, serverName); nextEvent.event("tablet %s was unloaded from %s", tablet, serverName); if (tls.walogs.isEmpty() && tls.chopped) return TabletGoalState.UNASSIGNED; return TabletGoalState.HOSTED; mergeStats.update(tls.extent, state, tls.chopped, !tls.walogs.isEmpty());
The Cyclomatic Complexity of this method "update" is 13 which is greater than 10 authorized.
* OptionDescribers will need to implement two methods: {@code describeOptions()} which returns an instance of {@link IteratorOptions} and * {@code validateOptions(Map<String,String> options)} which is intended to throw an exception or return false if the options are not acceptable. * IteratorOptions holds the name, description, and option information for an iterator. /** * Gets an iterator options object that contains information needed to configure this iterator. This object will be used by the accumulo shell to prompt the * user to input the appropriate information. * * @return an iterator options object */ /** * Check to see if an options map contains all options required by an iterator and that the option values are in the expected formats. * * @param options * a map of option names to option values * @return true if options are valid, false otherwise */
Replace this use of System.out or System.err by a logger.
if (Trace.isTracing()) span.data("length", Integer.toString(length)); if (Trace.isTracing()) span.data("length", Integer.toString(length)); if (Trace.isTracing()) span.data("length", Integer.toString(buffer.length));
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. */
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.PasswordToken;
1 duplicated blocks of code must be removed.
import org.apache.accumulo.trace.instrument.TraceRunnable; import org.apache.accumulo.trace.instrument.Tracer;
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
import org.apache.accumulo.proxy.thrift.PrincipalToken; protected static PrincipalToken userpass; userpass = new PrincipalToken("root", ByteBuffer.wrap("".getBytes())); public void ping() throws Exception { tpc.proxy().ping(userpass); } @Test
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper; import org.apache.accumulo.core.security.tokens.UserPassToken; Connector connector = instance.getConnector(new UserPassToken("root","")); InstanceTokenWrapper auths = new InstanceTokenWrapper(new UserPassToken("root", ""), "instance");
Immediately return this expression instead of assigning it to the temporary variable "ret".
public void initialize(String instanceId, boolean initialize) {
Remove this call to "exit" or ensure it is really required.
CreateRFiles.main(new String[] { "--output", "tmp/testmf", "--numThreads", "8", "--start", "0", "--end", "100000", "--splits", "99"}); VerifyIngest.main(new String[] {"--timestamp", "1", "--size", "50", "--random", "56", "--rows", "100000", "--start", "0", "--cols", "1"});
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
scanner.fetchColumnFamily(BulkPlusOne.CHECK_COLUMN_FAMILY);
This block of commented-out lines of code should be removed.
@Override public void cleanup() throws Exception {} @Override public Map<String,String> getInitialConfig() { Map<String,String> props = new HashMap<String,String>(); props.put(Property.TSERV_MAJC_DELAY.getKey(), "1s"); return props; } @Override public List<TableSetup> getTablesToCreate() { return Collections.singletonList(new TableSetup("de")); } @Override public void run() throws Exception { BatchWriter bw = getConnector().createBatchWriter("de", 1000000, 60000l, 1); Mutation m = new Mutation(new Text("foo")); m.put(new Text("bar"), new Text("1910"), new Value("5".getBytes())); bw.addMutation(m); bw.flush(); getConnector().tableOperations().flush("de", null, null, true); checkMapFiles("de", 1, 1, 1, 1); m = new Mutation(new Text("foo")); m.putDelete(new Text("bar"), new Text("1910")); bw.addMutation(m); bw.flush(); Scanner scanner = getConnector().createScanner("de", Constants.NO_AUTHS); scanner.setRange(new Range()); int count = 0; for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) { count++; if (count != 0) throw new Exception("count == " + count); getConnector().tableOperations().flush("de", null, null, true); getConnector().tableOperations().setProperty("de", Property.TABLE_MAJC_RATIO.getKey(), "1.0"); UtilWaitThread.sleep(4000); checkMapFiles("de", 1, 1, 0, 0); bw.close(); count = 0; for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) { count++; if (count != 0) throw new Exception("count == " + count); }
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. */ public int run(String[] args) throws Exception { Map<String,Long> totalBlocks = new HashMap<String,Long>(); Map<String,Long> localBlocks = new HashMap<String,Long>(); for (Entry<Key,Value> entry : scanner) { private void addBlocks(FileSystem fs, String host, ArrayList<String> files, Map<String,Long> totalBlocks, Map<String,Long> localBlocks) throws Exception { Path filePath = new Path(ServerConstants.getTablesDir() + "/" + file); public static void main(String[] args) throws Exception {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
import org.apache.accumulo.core.client.impl.thrift.ClientService.Iface; import org.apache.accumulo.core.util.Pair; public Repo<Master> call(final long tid, final Master master) throws Exception { if (master.onlineTabletServers().size() == 0) while (master.onlineTabletServers().size() == 0) { for (final String file : filesToLoad) { String server = null; Pair<String,Iface> pair = ServerClient.getConnection(master.getInstance()); client = pair.getSecond(); server = pair.getFirst(); List<String> attempt = Collections.singletonList(file); log.debug("Asking " + pair.getFirst() + " to bulk import " + file); List<String> fail = client.bulkImportFiles(null, SecurityConstants.getSystemCredentials(), tid, tableId, attempt, errorDir, setTime); if (fail.isEmpty()) { filesToLoad.remove(file); } else { failures.addAll(fail); log.error("rpc failed server:" + server + ", tid:" + tid + " " + ex, ex);
The Cyclomatic Complexity of this method "call" is 13 which is greater than 10 authorized.
package sample; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Results { @XmlElement private List<Document> document = new ArrayList<Document>(); public Results() { super(); } public List<Document> getResults() { return document; } public void setResults(List<Document> results) { this.document = results; } public int size() { if (null == document) return 0; else return document.size(); } }
Return empty string instead.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); indexMutation.put(new Text(s.description), new Text(s.sender), new Value((idString + ":" + Long.toHexString(diff)).getBytes(utf8))); connector = serverConfiguration.getInstance().getConnector(conf.get(Property.TRACE_USER), conf.get(Property.TRACE_PASSWORD).getBytes(utf8)); String path = zoo.putEphemeralSequential(root + "/trace-", name.getBytes(utf8));
Move this variable to comply with Java Code Conventions.
if (!shutdownState.equals(ShutdownState.REGISTERED)) throw new LoggerClosedException(); if (!root.startsWith("/")) root = System.getenv("ACCUMULO_HOME") + "/" + root; else if (root.equals("")) root = System.getProperty("org.apache.accumulo.core.dir.log"); if (fileLock == null) throw new IOException("Failed to acquire lock file"); if (!test.mkdir()) throw new RuntimeException("Unable to write to write-ahead log directory " + root);
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. */ package org.apache.accumulo.server.fs; import java.util.Random; public class RandomVolumeChooser implements VolumeChooser { Random random = new Random(); @Override public String choose(String[] options) { return options[random.nextInt(options.length)]; } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
log.info("Recovery complete for " + extent + " using " + logfile);
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.core.client.BatchWriterConfig; BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig());
Remove this unused method parameter "e".
package org.apache.accumulo.core.iterators.aggregation; import org.apache.accumulo.core.data.Value; public class StringSummation implements Aggregator { long sum = 0; public Value aggregate() { return new Value(Long.toString(sum).getBytes()); } public void collect(Value value) { sum += Long.parseLong(new String(value.get())); } public void reset() { sum = 0; } }
Return empty string instead.
import static org.junit.Assert.*; assertEquals(8, moved); assertEquals(48, moved);
6 duplicated blocks of code must be removed.
private TabletLocator locator; this.locator = new TimeoutTabletLocator(TabletLocator.getInstance(instance, credentials, new Text(table)), timeout); binRanges(locator, ranges, binnedRanges); binRanges(locator, allRanges, binnedRanges); locator.invalidateCache(tsFailures.keySet()); locator.invalidateCache(tsLocation);
Move this constructor to comply with Java Code Conventions.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import java.util.Set;
2 duplicated blocks of code must be removed.
resp.setContentType("text/xml;charset=UTF-8"); sb.append("<osload>").append(status.osLoad).append("</osload>\n"); sb.append("<ingest>").append(summary.ingestRate).append("</ingest>\n"); sb.append("<query>").append(summary.queryRate).append("</query>\n");
Remove the literal "false" boolean value.
import org.apache.hadoop.io.MapFile; FileStatus dataStatus = fs.getFileStatus(new Path(fileStatus.getPath(), MapFile.DATA_FILE_NAME));
Remove this unused method parameter "acuconf".
rands[i] = (r.nextLong() & 0x7fffffffffffffffl) % 10000000000l;
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.
if (iter != null) { mdScanner.close(); iter = null; } if (iter == null) return false; if (!result) { close(); } try { return fetch(); } catch (RuntimeException ex) { try { close(); } catch (Exception e) { log.error(e, e); } throw ex; }
Do not forget to remove this deprecated code someday.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @Override public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException { for (String user : shellState.getConnector().securityOperations().listUsers()) shellState.getReader().printString(user + "\n"); return 0; } @Override public String description() { return "displays a list of existing users"; } @Override public int numArgs() { return 0; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
tops.setProperty(indexTableName, stem, "19,org.apache.accumulo.examples.wikisearch.iterator.TotalAggregatingIterator"); tops.setProperty(indexTableName, stem + "*", "org.apache.accumulo.examples.wikisearch.aggregator.GlobalIndexUidAggregator"); tops.setProperty(reverseIndexTableName, stem, "19,org.apache.accumulo.examples.wikisearch.iterator.TotalAggregatingIterator"); tops.setProperty(reverseIndexTableName, stem + "*", "org.apache.accumulo.examples.wikisearch.aggregator.GlobalIndexUidAggregator");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* @deprecated since 1.4, use {@link TableOperations#attachIterator(String tableName, IteratorSetting setting)}
Do not forget to remove this deprecated code someday.
* * * * * *
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.cli.Help; import com.beust.jcommander.Parameter; * $ ./bin/accumulo accumulo.server.test.functional.RunTests --tests /user/hadoop/tests --output /user/hadoop/results static class Opts extends Help { @Parameter(names="--tests", description="newline separated list of tests to run", required=true) String testFile; @Parameter(names="--output", description="destination for the results of tests in HDFS", required=true) String outputPath; } Opts opts = new Opts(); opts.parseArgs(RunTests.class.getName(), args); TextInputFormat.setInputPaths(job, new Path(opts.testFile)); Path destination = new Path(opts.outputPath); log.info("Deleting existing output directory " + opts.outputPath);
Remove this unused private "appendProp" method.
@Override @Override public int hashCode() { return uris.hashCode() + (preDelegation ? Boolean.TRUE : Boolean.FALSE).hashCode(); } return getClassLoader(context).loadClass(classname).asSubclass(extension);
Reduce the number of conditional operators (6) used in the expression (maximum allowed 3).
import org.apache.accumulo.server.cli.ClientOpts; import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; static class Opts extends ClientOpts { @Parameter(names="--classname", required=true, description="name of the class under test") String classname = null; @Parameter(names="--opt", required=true, description="the options for test") String opt = null; } public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(FunctionalTest.class.getName(), args); Class<? extends FunctionalTest> testClass = AccumuloVFSClassLoader.loadClass(opts.classname, FunctionalTest.class); //fTest.setMaster(master); fTest.setUsername(opts.user); fTest.setPassword(new String(opts.getPassword())); fTest.setInstanceName(opts.instance); if (opts.opt.equals("getConfig")) { } else if (opts.opt.equals("setup")) { } else if (opts.opt.equals("run")) { } else if (opts.opt.equals("cleanup")) { printHelpAndExit("Unknown option: " + opts.opt); new JCommander(new Opts()).usage();
Remove this unused private "appendProp" method.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
296 duplicated blocks of code must be removed.
import org.apache.accumulo.fate.AdminUtil; import org.apache.accumulo.fate.ZooStore; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; AdminUtil<Master> admin = new AdminUtil<Master>(); String masterPath = ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK; admin.prepFail(zs, masterPath, args[1]); admin.prepDelete(zs, masterPath, args[1]); admin.deleteLocks(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, args[1]); admin.print(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS);
Remove this call to "exit" or ensure it is really required.
if (numSubBins < 2) return index; if (cutPointArray == null) throw new FileNotFoundException(cutFileName + " not found in distributed cache");
Remove this call to "exit" or ensure it is really required.