Diff
stringlengths
10
2k
Message
stringlengths
28
159
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
package org.apache.accumulo.test;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
import org.apache.accumulo.core.security.thrift.Credentials; synchronized public void fastHalt(TInfo tinfo, Credentials credentials, String lock) { public TabletServerStatus getTabletServerStatus(TInfo tinfo, Credentials credentials) throws ThriftSecurityException, TException { synchronized public void halt(TInfo tinfo, Credentials credentials, String lock) throws ThriftSecurityException, TException {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private static final String checkboxIdSuffix = "_checkbox"; private static final String pageLoadFunctionName = "pageload"; sb.append("function ").append(pageLoadFunctionName).append("() {\n"); sb.append(" var checkboxes = document.getElementsByTagName('input');\n"); sb.append(" for (var i = 0; i < checkboxes.length; i++) {\n"); sb.append(" if (checkboxes[i].checked) {\n"); sb.append(" var idSuffixOffset = checkboxes[i].id.indexOf('").append(checkboxIdSuffix).append("');\n"); sb.append(" var id = checkboxes[i].id.substring(0, idSuffixOffset);\n"); sb.append(" document.getElementById(id).style.display='table-row';\n"); sb.append(" }\n"); sb.append(" }\n"); sb.append("}\n"); if (hasData) { String hexSpanId = Long.toHexString(node.spanId); sb.append("<td><input type='checkbox' id=\""); sb.append(hexSpanId); sb.append(checkboxIdSuffix); sb.append("\" onclick='toggle(\"" + Long.toHexString(node.spanId) + "\")'></td>\n"); } else { } @Override protected String getBodyAttributes() { return " onload=\"" + pageLoadFunctionName + "()\" "; }
Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
AccumuloOutputFormat.setOutputInfo(job.getConfiguration(), args[0], args[1].getBytes(), true, args[5]); AccumuloOutputFormat.setZooKeeperInstance(job.getConfiguration(), args[3], args[4]);
1 duplicated blocks of code must be removed.
typeCheckValidFormat(PropertyType.ABSOLUTEPATH, "/foo", "/foo/c", "/"); // in hadoop 2.0 Path only normalizes Windows paths properly when run on a Windows system // this makes the following checks fail // typeCheckValidFormat(PropertyType.ABSOLUTEPATH, "d:\\foo12", "c:\\foo\\g", "c:\\foo\\c", "c:\\"); typeCheckInvalidFormat(PropertyType.ABSOLUTEPATH, "foo12", "foo/g", "foo\\c");
Remove this unused private "appendProp" method.
log.trace(String.format("Splitting at %6.2f instead of .5, row at .5 is same as end row%n", keys.firstKey()));
Use isEmpty() to check whether the collection is empty or not.
* Assign tablets to tablet servers. This method is called whenever the master finds tablets that are unassigned. * @param assignments * @param tableId * @return A list of TabletMigration object that passed sanity checks.
Either log or rethrow this exception.
private ReloadingClassLoader parent; ContextManager(FileSystemManager vfs, ReloadingClassLoader parent) { return loader.getClassLoader();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * @deprecated since 1.4 */
6 duplicated blocks of code must be removed.
import org.apache.accumulo.core.security.thrift.ThriftSecurityException;
1 duplicated blocks of code must be removed.
if (fs.getUsed() != 0) tableRow(sb, (highlight = !highlight), "%&nbsp;of&nbsp;Used&nbsp;DFS", consumed);
Either log or rethrow this exception.
public Process exec(Class<? extends Object> clazz, String... args) throws IOException { appendProp(fileWriter, Property.TRACE_LOGIN_PROPERTIES + ".password", config.getRootPassword(), siteConfig); appendProp(fileWriter, Property.TRACE_PORT, "" + getRandomFreePort(), siteConfig);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import static org.apache.accumulo.core.security.ColumnVisibility.quote; import static org.junit.Assert.assertEquals; import org.apache.accumulo.core.util.BadArgumentException; } catch (BadArgumentException e) { } catch (BadArgumentException e) { } catch (BadArgumentException e) { @Test public void testQuotedExpressions() throws VisibilityParseException { VisibilityEvaluator ct = new VisibilityEvaluator(ByteArraySet.fromStrings("A#C", "A\"C", "A\\C", "AC")); assertTrue(ct.evaluate(new ColumnVisibility(quote("A#C") + "|" + quote("A?C")))); assertTrue(ct.evaluate(new ColumnVisibility(new ColumnVisibility(quote("A#C") + "|" + quote("A?C")).flatten()))); assertTrue(ct.evaluate(new ColumnVisibility(quote("A\"C") + "&" + quote("A\\C")))); assertTrue(ct.evaluate(new ColumnVisibility(new ColumnVisibility(quote("A\"C") + "&" + quote("A\\C")).flatten()))); assertTrue(ct.evaluate(new ColumnVisibility("(" + quote("A\"C") + "|B)&(" + quote("A#C") + "|D)"))); assertFalse(ct.evaluate(new ColumnVisibility(quote("A#C") + "&B"))); assertTrue(ct.evaluate(new ColumnVisibility(quote("A#C")))); assertTrue(ct.evaluate(new ColumnVisibility("(" + quote("A#C") + ")"))); } @Test public void testQuote() { assertEquals("\"A#C\"", quote("A#C")); assertEquals("\"A\\\"C\"", quote("A\"C")); assertEquals("\"A\\\"\\\\C\"", quote("A\"\\C")); assertEquals("ACS", quote("ACS")); }
Reduce this switch case number of lines from 19 to at most 5, for example by extracting code into methods.
import org.apache.accumulo.core.util.MetadataTable; Scanner scanner = conn.createScanner(MetadataTable.NAME, opts.auths); scanner.fetchColumnFamily(MetadataTable.DATAFILE_COLUMN_FAMILY);
Use "Long.toString" instead.
import org.apache.accumulo.cloudtrace.instrument.Span; import org.apache.accumulo.cloudtrace.instrument.Trace; import org.apache.accumulo.cloudtrace.instrument.Tracer; import org.apache.accumulo.cloudtrace.instrument.receivers.ZooSpanClient;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
log.debug("Cloning table " + srcTableName + " " + newTableName + " " + flush);
Either log or rethrow this exception.
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, ServerConfiguration.getSystemConfiguration()); TabletClientService.Iface client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport); if (transport != null) transport.close();
Remove the literal "true" boolean value.
@Test(timeout = 3 * 60 * 1000) Process ingest = cluster.exec(TestIngest.class, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-u", "root", "-p", ROOT_PASSWORD, "--createTable"); @Test(timeout = 2 * 60 * 1000) assertEquals(0, cluster.exec(TestIngest.class, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-u", "root","-p", ROOT_PASSWORD, "--createTable").waitFor()); Process verify = cluster.exec(VerifyIngest.class, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-u", "root", "-p", ROOT_PASSWORD); @Test(timeout = 2 * 60 * 1000) assertEquals(0, cluster.exec(TestIngest.class, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-u", "root", "-p", ROOT_PASSWORD, "--createTable").waitFor()); Process deleter = cluster.exec(TestRandomDeletes.class, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-u", "root", "-p", ROOT_PASSWORD); @Test(timeout = 60 * 1000) @Test(timeout = 4 * 60 * 1000) @Test(timeout = 2 * 60 * 1000) assertEquals(0, cluster.exec(TestIngest.class, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-u", "root", "-p", ROOT_PASSWORD, "--createTable").waitFor());
Either log or rethrow this exception.
ZooKeeperInstance instance = new ZooKeeperInstance(accumulo.getConfig().getInstanceName(), accumulo.getConfig().getZooKeepers());
Either log or rethrow this exception.
* 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
Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.Credentials; public TabletLocations lookupTablet(Credentials credentials, TabletLocation src, Text row, Text stopRow, TabletLocator parent) boolean more = ThriftScanner.getBatchFromServer(instance, credentials, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, more = ThriftScanner.getBatchFromServer(instance, credentials, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, false, instance.getConfiguration()); public List<TabletLocation> lookupTablets(Credentials credentials, String tserver, Map<KeyExtent,List<Range>> tabletsRanges, TabletLocator parent) TabletServerBatchReaderIterator.doLookup(instance, credentials, tserver, tabletsRanges, failures, unscanned, rr, columns, opts, Authorizations.EMPTY,
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.core.metadata; import java.util.SortedMap; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.data.KeyExtent; import org.apache.accumulo.core.security.thrift.TCredentials; /** * A metadata servicer for the root table.<br /> * The root table's metadata is serviced in zookeeper. */ class ServicerForRootTable extends MetadataServicer { private Instance instance; public ServicerForRootTable(Instance instance, TCredentials credentials) { this.instance = instance; } @Override public String getServicedTableId() { return RootTable.ID; } @Override public void getTabletLocations(SortedMap<KeyExtent,String> tablets) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { tablets.put(RootTable.EXTENT, instance.getRootTabletLocation()); } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * @deprecated since 1.4 * @use org.apache.accumulo.core.iterators.user.SummingCombiner with SummingCombiner.Type.LONG */
Either log or rethrow this exception.
package org.apache.accumulo.test.randomwalk.shard; import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
if (bytes > 0 && Integer.parseInt(setting) > 10) { log.warn("System swappiness setting is greater than ten (" + setting + ") which can cause time-sensitive operations to be delayed. "
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ private static final long serialVersionUID = 1L; public final static Level TABLET_HIST = new TLevel(); protected TLevel() { super(Level.DEBUG_INT + 100, "TABLET_HIST", Level.DEBUG_INT + 100); } static public Level toLevel(int val) { if (val == Level.DEBUG_INT + 100) return Level.DEBUG; return Level.toLevel(val); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.core.client.lexicoder; import static org.apache.accumulo.core.client.lexicoder.util.ByteUtils.escape; import static org.apache.accumulo.core.client.lexicoder.util.ByteUtils.unescape; public class ReverseLexicoder<T> implements Lexicoder<T> { private Lexicoder<T> lexicoder; public ReverseLexicoder(Lexicoder<T> lexicoder) { this.lexicoder = lexicoder; } @Override public byte[] encode(T data) { byte[] bytes = escape(lexicoder.encode(data)); byte[] ret = new byte[bytes.length + 1]; for (int i = 0; i < bytes.length; i++) ret[i] = (byte) (0xff - (0xff & bytes[i])); ret[bytes.length] = (byte) 0xff; return ret; } @Override public T decode(byte[] data) { byte ret[] = new byte[data.length - 1]; for (int i = 0; i < ret.length; i++) ret[i] = (byte) (0xff - (0xff & data[i])); return lexicoder.decode(unescape(ret)); } }
Rename this generic name to match the regular expression '^[A-Z]$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
/* * 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.security.tokens.AuthenticationToken;
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 org.apache.accumulo.core.client.MutationsRejectedException; try { mtbw.close(); } catch (MutationsRejectedException e) { throw new RuntimeException(e); }
Define and throw a dedicated exception instead of using a generic one.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ String indexTableName = (String) state.get("indexTableName"); if (splits.size() > splitSet.size()) { // throw an excpetion so that test will die an no further changes to table will occur... // this way table is left as is for debugging.
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* 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
Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.
/** * @deprecated since 1.4 * @param conf * @param fs * @param dirName * @return */ @SuppressWarnings("deprecation") @SuppressWarnings("deprecation") /** * @deprecated sicne 1.4 * * @param acuTableConf * @param conf * @param fs * @param dirname * @return * @throws IOException */
6 duplicated blocks of code must be removed.
* @since 1.5.0
Move this constructor to comply with Java Code Conventions.
import org.apache.accumulo.core.security.thrift.TCredentials; private TCredentials credentials; public TableOperationsImpl(Instance instance, TCredentials credentials) {
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.
package org.apache.accumulo.fate.zookeeper; import org.apache.accumulo.fate.zookeeper.ZooReaderWriter.Mutator; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
Remove this call to "exit" or ensure it is really required.
zoo.putPersistentData(zTablePath + Constants.ZTABLE_NAME, tableName.getBytes(), existsPolicy); zoo.putPersistentData(zTablePath + Constants.ZTABLE_STATE, state.name().getBytes(), existsPolicy); zoo.putPersistentData(zTablePath + Constants.ZTABLE_FLUSH_ID, "0".getBytes(), existsPolicy); zoo.putPersistentData(zTablePath + Constants.ZTABLE_COMPACT_ID, "0".getBytes(), existsPolicy); ZooReaderWriter.getRetryingInstance().mutate(statePath, (byte[]) newState.name().getBytes(), ZooUtil.PUBLIC, new Mutator() { return newState.name().getBytes();
Remove this unused method parameter "ex".
@Deprecated @Deprecated
3 duplicated blocks of code must be removed.
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
1 duplicated blocks of code must be removed.
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.AgeOffFilter}
Either log or rethrow this exception.
Collection<Text> splits = conn.tableOperations().listSplits(tableName, maxSplits);
Either log or rethrow this exception.
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper; private InstanceTokenWrapper credentials; public TabletServerBatchDeleter(Instance instance, InstanceTokenWrapper credentials, String tableId, Authorizations authorizations, int numQueryThreads,
Immediately return this expression instead of assigning it to the temporary variable "ret".
IDLE, RUNNING, QUEUED
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.
private final Callable<V> impl; private final Span parent; TraceCallable(Callable<V> impl) { this(Trace.currentTrace(), impl); } TraceCallable(Span parent, Callable<V> impl) { this.impl = impl; this.parent = parent; } @Override public V call() throws Exception { if (parent != null) { Span chunk = Trace.startThread(parent, Thread.currentThread().getName()); try { return impl.call(); } finally { Trace.endThread(chunk); } } else { return impl.call(); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private final TabletTime tabletTime; private final Object timeLock = new Object(); public final Object bulkFileImportLock = new Object(); private final ReentrantLock logLock = new ReentrantLock();
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. */ package org.apache.accumulo.core.security.handler; import java.util.Properties; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.security.thrift.tokens.NullToken; import org.apache.accumulo.core.security.thrift.tokens.SecurityToken; /** * */ public class InsecureAuthenticator implements Authenticator { @Override public SecurityToken login(Properties properties) throws AccumuloSecurityException { return new NullToken(); } }
Make the "log" logger private static final and rename it to comply with the format "LOG(?:GER)?".
import static org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy.SKIP;
Remove this call to "exit" or ensure it is really required.
if (pkey == null) return null;
Return empty string instead.
if (!shellState.getConnector().tableOperations().exists(tableName)) throw new TableNotFoundException(null, tableName, null); if (sa.length < 2) throw new IllegalArgumentException("Missing '='");
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.core.security.Credentials; public TabletLocation locateTablet(Credentials credentials, Text row, boolean skipRow, boolean retry) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { public <T extends Mutation> void binMutations(Credentials credentials, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { public List<Range> binRanges(Credentials credentials, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
if (everythingLooksGood) System.out.println("All is well for table " + tablename); else sawProblems = true; if (sawProblems) System.exit(-1);
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.cloudtrace.instrument.Tracer; return client.beginTableOperation(Tracer.traceInfo(), credentials); client.executeTableOperation(Tracer.traceInfo(), credentials, opid, op, args, opts, autoCleanUp); return client.waitForTableOperation(Tracer.traceInfo(), credentials, opid); client.finishTableOperation(Tracer.traceInfo(), credentials, opid); TabletClientService.Client client = ThriftUtil.getTServerClient(tl.tablet_location, instance.getConfiguration()); client.splitTablet(Tracer.traceInfo(), credentials, tl.tablet_extent.toThrift(), TextUtil.getByteBuffer(split)); ThriftUtil.returnClient(client); flushID = client.initiateFlush(Tracer.traceInfo(), credentials, tableId); client.waitForFlush(Tracer.traceInfo(), credentials, tableId, TextUtil.getByteBuffer(start), TextUtil.getByteBuffer(end), flushID, wait ? Long.MAX_VALUE : 1); MasterClient.execute(instance, new ClientExec<MasterClientService.Client>() { public void execute(MasterClientService.Client client) throws Exception { client.setTableProperty(Tracer.traceInfo(), credentials, tableName, property, value); MasterClient.execute(instance, new ClientExec<MasterClientService.Client>() { public void execute(MasterClientService.Client client) throws Exception { client.removeTableProperty(Tracer.traceInfo(), credentials, tableName, property); return ServerClient.executeRaw(instance, new ClientExecReturn<Map<String,String>,ClientService.Client>() { public Map<String,String> execute(ClientService.Client client) throws Exception {
Immediately return this expression instead of assigning it to the temporary variable "client".
package org.apache.accumulo.server.test.randomwalk.multitable; import java.net.InetAddress; import java.util.ArrayList; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.server.test.randomwalk.Fixture; import org.apache.accumulo.server.test.randomwalk.State; public class MultiTableFixture extends Fixture { @Override public void setUp(State state) throws Exception { String hostname = InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_"); state.set("tableNamePrefix", String.format("multi_%s_%s_%d", hostname, state.getPid(), System.currentTimeMillis())); state.set("nextId", new Integer(0)); state.set("numWrites", new Integer(0)); state.set("totalWrites", new Integer(0)); state.set("tableList", new ArrayList<String>()); } @Override public void tearDown(State state) throws Exception { Connector conn = state.getConnector(); @SuppressWarnings("unchecked") ArrayList<String> tables = (ArrayList<String>) state.get("tableList"); for (String tableName : tables) { try { conn.tableOperations().delete(tableName); log.debug("Dropping table "+tableName); } catch (TableNotFoundException e) { log.warn("Tried to drop table "+tableName+" but could not be found!"); } } } }
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. */ /** * 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.proxy.thrift; import java.util.Map; import java.util.HashMap; import org.apache.thrift.TEnum; @SuppressWarnings("all") public enum PTimeType implements org.apache.thrift.TEnum { LOGICAL(0), MILLIS(1); private final int value; private PTimeType(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 PTimeType findByValue(int value) { switch (value) { case 0: return LOGICAL; case 1: return MILLIS; default: return null; } } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (rootWriter != null) { try { rootWriter.close(); } catch (MutationsRejectedException e) { log.error("Problem removing entries from the metadata table: ", e); } }
1 duplicated blocks of code must be removed.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.util.MetadataTable; import org.apache.accumulo.core.util.RootTable; @Parameter(names = "-update", description = "Make changes to the " + MetadataTable.NAME + " table to include missing files") * A utility to add files to the {@value MetadataTable#NAME} table that are not listed in the root tablet. This is a recovery tool for someone who final Key rootTableEnd = new Key(RootTable.ROOT_TABLET_EXTENT.getEndRow()); final Range range = new Range(rootTableEnd.followingKey(PartialKey.ROW), true, MetadataTable.RESERVED_KEYSPACE_START_KEY, false); final Scanner scanner = opts.getConnector().createScanner(MetadataTable.NAME, Authorizations.EMPTY); if (MetadataTable.DIRECTORY_COLUMN.hasColumns(key)) { } else if (key.compareColumnFamily(MetadataTable.DATAFILE_COLUMN_FAMILY) == 0) { m.put(MetadataTable.DATAFILE_COLUMN_FAMILY, new Text(filename), new Value(value.getBytes())); writer.getBatchWriter(MetadataTable.NAME).addMutation(m);
Use "Long.toString" instead.
// Not really deprecated, just discouraging client use.
Define a constant instead of duplicating this literal "org.apache.accumulo.core.iterators.WholeRowIterator" 4 times.
@Test(timeout=30*1000)
Either log or rethrow this exception.
log.info("Zookeeper error, will retry", e);
Reorder the modifiers to comply with the Java Language Specification.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class DefaultMap<K,V> extends HashMap<K,V> { public DefaultMap(V dfault) { this.dfault = dfault; } super.put((K) key, result = construct()); return (V) dfault.getClass().newInstance();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; Map<String,String> settings = new HashMap<String,String>(); @Test(timeout = 60 * 1000) UtilWaitThread.sleep(5 * 1000); @Test(timeout = 60 * 1000) UtilWaitThread.sleep(10 * 1000); Path path = new Path(cluster.getConfig().getDir() + "/accumulo/tables/1/*/*.rf"); for (@SuppressWarnings("unused") FileStatus entry : fs.globStatus(path)) { Text row = new Text(String.format("%s%s%020d%s", MetadataSchema.DeletesSection.getRowPrefix(), "/", i,
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.server.util.MetadataTableUtil; MetadataTableUtil.LogEntry logEntry = new MetadataTableUtil.LogEntry();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
return address;
Remove this unused method parameter "threadName".
import org.apache.accumulo.core.security.thrift.ThriftSecurityException; import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper; public void initializeSecurity(InstanceTokenWrapper credentials, String rootuser) throws AccumuloSecurityException, ThriftSecurityException;
Immediately return this expression instead of assigning it to the temporary variable "ret".
import org.apache.accumulo.core.security.Authorizations; Scanner scanner = getConnector().createScanner("bwlt", Authorizations.EMPTY); Scanner scanner = getConnector().createScanner("bwft", Authorizations.EMPTY);
Remove this unused method parameter "range".
@Override public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException { shellState.getConnector().tableOperations().rename(cl.getArgs()[0], cl.getArgs()[1]); if (shellState.getTableName().equals(cl.getArgs()[0])) shellState.setTableName(cl.getArgs()[1]); return 0; } @Override public String usage() { return getName() + " <current table name> <new table name>"; } @Override public String description() { return "rename a table"; } public void registerCompletion(Token root, Map<Command.CompletionSet,Set<String>> completionSet) { registerCompletionForTables(root, completionSet); } @Override public int numArgs() { return 2; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public static class TColumnTranslator extends Translator<TColumn,Column> { @Override public Column translate(TColumn input) { return new Column(input); } }
Remove this unused method parameter "range".
import org.apache.accumulo.core.util.shell.Token; throw new BadArgumentException("Property cannot be modified in zookeeper", fullCommand, fullCommand.indexOf(property));
Remove the literal "true" boolean value.
* @return The results of a query
1 duplicated blocks of code must be removed.
String _val47; // required String _val53; // required
Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-z0-9]*)*$'.
org.apache.accumulo.core.data.thrift.TConstraintViolationSummary _elem2; // optional org.apache.accumulo.core.data.thrift.TConstraintViolationSummary _elem7; // optional
277 duplicated blocks of code must be removed.
zoo.recursiveDelete(ZooUtil.getRoot(instance) + "/loggers", NodeMissingPolicy.SKIP); zoo.recursiveDelete(ZooUtil.getRoot(instance) + "/dead/loggers", NodeMissingPolicy.SKIP);
1 duplicated blocks of code must be removed.
/** * @param prevExtent */ public boolean isPreviousExtent(KeyExtent prevExtent) { if (prevExtent == null) return getPrevEndRow() == null; if (!prevExtent.getTableId().equals(getTableId())) throw new IllegalArgumentException("Cannot compare accross tables " + prevExtent + " " + this); if (prevExtent.getEndRow() == null) return false; if (getPrevEndRow() == null) return false; return prevExtent.getEndRow().equals(getPrevEndRow()); }
Reduce the total number of break and continue statements in this loop to use at most one.
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.TreeSet; @Override public List<Set<AuthProperty>> getProperties() { List<Set<AuthProperty>> toRet = new LinkedList<Set<AuthProperty>>(); Set<AuthProperty> internal = new TreeSet<AuthProperty>(); internal.add(new AuthProperty("password", "the password for the principal")); toRet.add(internal); return toRet; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
String logConfig = String.format("%s/%s_logger.xml", System.getenv("ACCUMULO_CONF_DIR"), application); logConfig = String.format("%s/generic_logger.xml", System.getenv("ACCUMULO_CONF_DIR"));
Remove the literal "false" boolean value.
private Option mincScopeOpt, majcScopeOpt, scanScopeOpt, nameOpt; public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception { String tableName = OptUtil.configureTableOpt(cl, shellState); o.addOption(OptUtil.tableOpt("table to delete the iterator from"));
Reduce this switch case number of lines from 8 to at most 5, for example by extracting code into methods.
public boolean hasTop() { throw new NullPointerException(); } @Override
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Remove the literal "true" boolean value.
private final Instance instance; MockConnector(String username, Instance instance) { this(username, new MockAccumulo(), instance); MockConnector(String username, MockAccumulo acu, Instance instance) { this.instance = instance; return instance;
Return empty string instead.
import java.util.List; import org.apache.accumulo.core.client.IteratorSetting; public Map<String,List<IteratorSetting>> scanIteratorOptions = new HashMap<String,List<IteratorSetting>>(); for (Entry<String,List<IteratorSetting>> entry : scanIteratorOptions.entrySet()) { for (IteratorSetting setting : entry.getValue()) { sb.append("- Iterator ").append(setting.getName()).append(" options:\n"); sb.append("- ").append("iteratorPriority").append(" = ").append(setting.getPriority()).append("\n"); sb.append("- ").append("iteratorClassName").append(" = ").append(setting.getIteratorClass()).append("\n"); for (Entry<String,String> optEntry : setting.getProperties().entrySet()) {
Remove the literal "true" boolean value.
import org.apache.accumulo.core.cli.ClientOnRequiredTable; import com.beust.jcommander.Parameter; static class Opts extends ClientOnRequiredTable { @Parameter(names="--output", description="output directory") String output; @Parameter(names="--reducers", description="number of reducers to use", required=true) int reducers; @Parameter(names="--offline", description="run against an offline table") boolean offline = false; } Opts opts = new Opts(); opts.parseArgs(UniqueColumns.class.getName(), args); String clone = opts.tableName; if (opts.offline) { conn = opts.getConnector(); clone = opts.tableName + "_" + jobName; conn.tableOperations().clone(opts.tableName, clone, true, new HashMap<String,String>(), new HashSet<String>()); opts.setAccumuloConfigs(job); job.setNumReduceTasks(opts.reducers); TextOutputFormat.setOutputPath(job, new Path(opts.output)); if (opts.offline) {
Remove this call to "exit" or ensure it is really required.
package org.apache.accumulo.test.randomwalk.concurrent; import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
import java.util.Collections; import java.util.Properties; import java.util.Set; @Override public void init(Properties properties) {} @Override public Set<TokenProperty> getProperties() { return Collections.emptySet(); }
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
/* * 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 (objectsCol.contains(lookupCol)) return true;
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. */
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.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Remove this unused private "appendProp" method.
* Scans a table over a given range. * This setting determines how long a scanner will automatically retry when a failure occurs. By default a scanner will retry forever. * Returns the setting for how long a scanner will automatically retry when a failure occurs. * * Sets the range of keys to scan over. * * Returns the range of keys to scan over. * * Sets the number of Key/Value pairs that will be fetched at a time from a tablet server. * * the number of Key/Value pairs to fetch per call to Accumulo * Returns the batch size (number of Key/Value pairs) that will be fetched at a time from a tablet server. * /** * Enables row isolation. Writes that occur to a row after a scan of that row has begun will not be seen if this option is enabled. */ /** * Disables row isolation. Writes that occur to a row after a scan of that row has begun may be seen if this option is enabled. */
Complete the task associated to this TODO comment.
import org.apache.accumulo.proxy.thrift.UserPass; protected static ByteBuffer userpass; userpass = tpc.proxy().login(new UserPass("root", ByteBuffer.wrap("".getBytes()))); tpc.proxy().changeUserPassword(userpass, testuser, ByteBuffer.wrap("newpass".getBytes()));
Immediately return this expression instead of assigning it to the temporary variable "connector".
import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import org.apache.commons.codec.binary.Base64; public static final String HEADER = "!AUTH1:"; authsList.add(bs.toArray()); /** * @param authorizations * a serialized authorizations string produced by {@link #getAuthorizationsArray()} or {@link #serialize()} */ String authsString = new String(authorizations); if (authsString.startsWith(HEADER)) { // its the new format for (String encAuth : authsString.substring(HEADER.length()).split(",")) { byte[] auth = Base64.decodeBase64(encAuth.getBytes()); auths.add(new ArrayByteSequence(auth)); } checkAuths(); } else { // its the old format ArgumentChecker.notNull(authorizations); if (authorizations.length > 0) setAuthorizations(authsString.split(",")); } /** * * @param charset * used to convert each authorization to a byte array * @param authorizations * array of authorizations */ public Authorizations(Charset charset, String... authorizations) { setAuthorizations(charset, authorizations); } setAuthorizations(Charset.defaultCharset(), authorizations); } private void setAuthorizations(Charset charset, String... authorizations) { try { auths.add(new ArrayByteSequence(str.getBytes(charset.name()))); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } return serialize().getBytes(); StringBuilder sb = new StringBuilder(); String sep = ""; for (ByteSequence auth : auths) { sb.append(sep); sep = ","; sb.append(new String(auth.toArray())); } return sb.toString(); StringBuilder sb = new StringBuilder(HEADER); sb.append(new String(Base64.encodeBase64(auth.toArray())));
Move this constructor to comply with Java Code Conventions.
import static org.junit.Assert.*; assertEquals(1, groups.size()); assertNotNull(groups.get("lg1")); assertEquals(2, groups.get("lg1").size()); assertTrue(groups.get("lg1").contains(new ArrayByteSequence("cf1"))); fail(); fail(); assertEquals(bs1, bs2); assertEquals(ecf, LocalityGroupUtil.encodeColumnFamily(bs2)); assertEquals(in2, out);
Remove this unused private "appendProp" method.