Diff
stringlengths
10
2k
Message
stringlengths
28
159
package org.apache.accumulo.examples.shard; import java.util.Collections; import java.util.Map.Entry; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.BatchScanner; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.ZooKeeperInstance; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.IntersectingIterator; import org.apache.hadoop.io.Text; /** * This program queries a set of terms in the shard table * (populated by Index.java) using the intersecting iterator. * */ public class Query { /** * @param args */ public static void main(String[] args) throws Exception { if(args.length < 6){ System.err.println("Usage : "+Query.class.getName()+" <instance> <zoo keepers> <table> <user> <pass> <term>{ <term>}"); System.exit(-1); } String instance = args[0]; String zooKeepers = args[1]; String table = args[2]; String user = args[3]; String pass = args[4]; ZooKeeperInstance zki = new ZooKeeperInstance(instance, zooKeepers); Connector conn = zki.getConnector(user, pass.getBytes()); BatchScanner bs = conn.createBatchScanner(table, Constants.NO_AUTHS, 20); Text columns[] = new Text[args.length - 5]; for(int i = 5; i < args.length; i++){ columns[i-5] = new Text(args[i]); } IteratorSetting ii = new IteratorSetting(20, "ii", IntersectingIterator.class); ii.addOption(IntersectingIterator.columnFamiliesOptionName, IntersectingIterator.encodeColumns(columns)); bs.addScanIterator(ii); bs.setRanges(Collections.singleton(new Range())); for (Entry<Key,Value> entry : bs) { System.out.println(" "+entry.getKey().getColumnQualifier()); } } }
Return empty string instead.
package org.apache.accumulo.examples.simple.filedata;
Rename "table" which hides the field declared at line 107.
* 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 SortedSetAggregator implements Aggregator { TreeSet<String> items = new TreeSet<String>(); // aggregate the entire set of items, in sorted order public Value aggregate() { return new Value(StringUtil.join(items, ",").getBytes()); } // allow addition of multiple items at a time to the set public void collect(Value value) { String[] strings = value.toString().split(","); for (String s : strings) items.add(s); } public void reset() { items.clear(); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (redir != null) redir = decode(redir); if (redir != null) resp.sendRedirect(redir); else resp.sendRedirect("/"); if (resource != null) resource = decode(resource); if (ptype != null) ptype = decode(ptype); if (table == null || page == null || (asc == null && col == null)) return; if (asc == null) resp.addCookie(new Cookie("tableSort." + page + "." + table + "." + "sortCol", col)); else resp.addCookie(new Cookie("tableSort." + page + "." + table + "." + "sortAsc", asc)); if (table == null || page == null || show == null) return;
Remove this call to "exit" or ensure it is really required.
private TemporaryFolder folder1 = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target")); private TemporaryFolder folder2 = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.SecurityToken; * <li>{@link AccumuloOutputFormat#setConnectorInfo(JobConf, SecurityToken)} OR {@link AccumuloOutputFormat#setConnectorInfo(JobConf, Path)} * @throws AccumuloSecurityException public static void setConnectorInfo(JobConf job, SecurityToken token) throws AccumuloSecurityException { * {@link TokenHelper#asBase64String(SecurityToken)}. * the path to a file in the configured file system, containing the serialized, base-64 encoded {@link SecurityToken} with the user's authentication * @see #setConnectorInfo(JobConf, SecurityToken) * @throws AccumuloSecurityException * @see #setConnectorInfo(JobConf, SecurityToken) protected static SecurityToken getToken(JobConf job) throws AccumuloSecurityException {
Either log or rethrow this exception.
static Configuration getConfiguration(JobContext context) {
2 duplicated blocks of code must be removed.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
@Override public String description() { return "starts the process of taking table offline"; } protected void doTableOp(Shell shellState, String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (tableName.equals(Constants.METADATA_TABLE_NAME)) { Shell.log.info(" You cannot take the " + Constants.METADATA_TABLE_NAME + " offline."); } else { Shell.log.info("Attempting to begin taking " + tableName + " offline"); shellState.getConnector().tableOperations().offline(tableName); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.hadoop.conf.Configuration; Configuration conf = job.getConfiguration(); AccumuloInputFormat.setInputInfo(conf, "root", "".getBytes(), "testtable1", new Authorizations()); AccumuloInputFormat.setMockInstance(conf, "testmrinstance"); AccumuloOutputFormat.setOutputInfo(conf, "root", "".getBytes(), false, "testtable2"); AccumuloOutputFormat.setMockInstance(conf, "testmrinstance");
This block of commented-out lines of code should be removed.
import org.apache.accumulo.core.security.tokens.SecurityToken; * @deprecated Use {@link #createUser(SecurityToken)} instead * @deprecated @since 1.5, use {@link #createUser(SecurityToken)} public void createUser(SecurityToken token, Authorizations authorization) throws AccumuloException, AccumuloSecurityException { public void createUser(SecurityToken token) throws AccumuloException, AccumuloSecurityException { public boolean authenticateUser(SecurityToken token) throws AccumuloException, AccumuloSecurityException { * @deprecated @since 1.5, use {@link #changeUserPassword(SecurityToken)} public void changeUserPassword(SecurityToken token) throws AccumuloException, AccumuloSecurityException { user.password = upt.getPassword();
Either log or rethrow this exception.
state.getConnector().tableOperations().offline(tableName, rand.nextBoolean()); state.getConnector().tableOperations().online(tableName, rand.nextBoolean());
Cast one of the operands of this multiplication operation to a "long".
package org.apache.accumulo.server.monitor.util.celltypes; import java.net.InetSocketAddress; import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.util.AddressUtil; public class TServerLinkType extends CellType<TabletServerStatus> { @Override public String format(Object obj) { if (obj == null) return "-"; TabletServerStatus status = (TabletServerStatus) obj; return String.format("<a href='/tservers?s=%s'>%s</a>", status.name, displayName(status)); } public static String displayName(TabletServerStatus status) { return displayName(status == null ? null : status.name); } public static String displayName(String address) { if (address == null) return "--Unknown--"; InetSocketAddress inetAddress = AddressUtil.parseAddress(address, 0); return inetAddress.getHostName() + ":" + inetAddress.getPort(); } @Override public int compare(TabletServerStatus o1, TabletServerStatus o2) { return displayName(o1).compareTo(displayName(o2)); } @Override public String alignment() { return "left"; } }
Return empty string instead.
import org.apache.accumulo.cloudtrace.thrift.RemoteSpan;
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. */ import java.util.TreeMap; private TreeMap<Key,Value> getBuffer(Text tablename) { if (buffer == null) { private Text getLargestTablename() { for (Entry<Text,Long> e : bufferSizes.entrySet()) { if (e.getValue() > max) { private void flushLargestTable() throws IOException { if (tablename == null) while (size > 0) for (ColumnUpdate update : mutation.getUpdates()) { Key k = new Key(mutation.getRow(), update.getColumnFamily(), update.getColumnQualifier(), update.getColumnVisibility(), update.getTimestamp(), update.isDeleted());
Move this variable to comply with Java Code Conventions.
assertTrue(iterator.hasNext()); assertEquals(key.getColumnQualifier(), new Text("5000000000000000")); assertFalse(iterator.hasNext());
6 duplicated blocks of code must be removed.
new ColumnVisibility(value); // validate that it is a valid expression
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. */ /** * 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 PScanState implements org.apache.thrift.TEnum { IDLE(0), RUNNING(1), QUEUED(2); private final int value; private PScanState(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 PScanState findByValue(int value) { switch (value) { case 0: return IDLE; case 1: return RUNNING; case 2: return QUEUED; default: return null; } } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private Connector conn = null; List<Entry<Key,Value>> lastRefs; private ChunkInputStream cis; Scanner scanner; public FileDataQuery(String instanceName, String zooKeepers, String user, String password, String tableName, Authorizations auths) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers); conn = instance.getConnector(user, password.getBytes()); lastRefs = new ArrayList<Entry<Key,Value>>(); cis = new ChunkInputStream(); scanner = conn.createScanner(tableName, auths); } public List<Entry<Key,Value>> getLastRefs() { return lastRefs; } public ChunkInputStream getData(String hash) { scanner.setRange(new Range(hash)); scanner.setBatchSize(1); lastRefs.clear(); PeekingIterator<Entry<Key,Value>> pi = new PeekingIterator<Entry<Key,Value>>(scanner.iterator()); if (pi.hasNext()) { while (!pi.peek().getKey().getColumnFamily().equals(FileDataIngest.CHUNK_CF)) { lastRefs.add(pi.peek()); pi.next(); } cis.clear(); cis.setSource(pi); return cis; } public String getSomeData(String hash, int numBytes) throws IOException { ChunkInputStream is = getData(hash); byte[] buf = new byte[numBytes]; if (is.read(buf) >= 0) { return new String(buf); } else { return ""; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private static final String PREFIX = AccumuloFileOutputFormatTest.class.getSimpleName(); private static final String INSTANCE_NAME = PREFIX + "_mapreduce_instance"; private static final String BAD_TABLE = PREFIX + "_mapreduce_bad_table"; private static final String TEST_TABLE = PREFIX + "_mapreduce_test_table"; private static final String EMPTY_TABLE = PREFIX + "_mapreduce_empty_table"; MockInstance mockInstance = new MockInstance(INSTANCE_NAME); c.tableOperations().create(EMPTY_TABLE); c.tableOperations().create(TEST_TABLE); c.tableOperations().create(BAD_TABLE); BatchWriter bw = c.createBatchWriter(TEST_TABLE, new BatchWriterConfig()); bw = c.createBatchWriter(BAD_TABLE, new BatchWriterConfig()); AccumuloInputFormat.setMockInstance(job, INSTANCE_NAME); job.setMapperClass(BAD_TABLE.equals(table) ? BadKeyMapper.class : Mapper.class); MRTester.main(new String[] {"root", "", content ? TEST_TABLE : EMPTY_TABLE, f.getAbsolutePath()}); MRTester.main(new String[] {"root", "", BAD_TABLE, f.getAbsolutePath()});
Either log or rethrow this exception.
* @use org.apache.accumulo.core.iterators.Filter
Remove this unused private "match" method.
public String getZooKeepers() {
Define a constant instead of duplicating this literal "digest" 13 times.
import java.util.UUID; import org.apache.accumulo.proxy.thrift.TableExistsException; import org.apache.accumulo.proxy.thrift.UnknownScanner; import org.apache.accumulo.proxy.thrift.UnknownWriter; public void testExists() throws Exception { client.createTable(creds, "ett1", false, TimeType.MILLIS); client.createTable(creds, "ett2", false, TimeType.MILLIS); try { client.createTable(creds, "ett1", false, TimeType.MILLIS); fail("exception not thrown"); } catch (TableExistsException tee) {} try { client.renameTable(creds, "ett1", "ett2"); fail("exception not thrown"); } catch (TableExistsException tee) {} try { client.cloneTable(creds, "ett1", "ett2", false, new HashMap<String,String>(), new HashSet<String>()); fail("exception not thrown"); } catch (TableExistsException tee) {} } @Test(timeout = 10000) public void testUnknownScanner() throws Exception { try { client.nextEntry("99999999"); fail("exception not thrown"); } catch (UnknownScanner us) {} try { client.nextK("99999999", 6); fail("exception not thrown"); } catch (UnknownScanner us) {} try { client.hasNext("99999999"); fail("exception not thrown"); } catch (UnknownScanner us) {} try { client.hasNext(UUID.randomUUID().toString()); fail("exception not thrown"); } catch (UnknownScanner us) {} } @Test(timeout = 10000) public void testUnknownWriter() throws Exception { try { client.flush("99999"); fail("exception not thrown"); } catch (UnknownWriter uw) {} try { client.flush(UUID.randomUUID().toString()); fail("exception not thrown"); } catch (UnknownWriter uw) {} try { client.closeWriter("99999"); fail("exception not thrown"); } catch (UnknownWriter uw) {} } @Test(timeout = 10000)
Either log or rethrow this exception.
import org.apache.accumulo.trace.instrument.Tracer; import org.apache.accumulo.trace.thrift.TInfo;
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
/** * provides scanner functionality * * "Clients can iterate over multiple column families, and there are several * mechanisms for limiting the rows, columns, and timestamps traversed by a * scan. For example, we could restrict [a] scan ... to only produce anchors * whose columns match [a] regular expression ..., or to only produce * anchors whose timestamps fall within ten days of the current time." * */
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.
package org.apache.accumulo.examples.simple.constraints;
Rename "table" which hides the field declared at line 107.
import org.apache.accumulo.core.security.thrift.ThriftSecurityException;
1 duplicated blocks of code must be removed.
package org.apache.accumulo.examples.simple.filedata; import org.apache.accumulo.examples.simple.filedata.ChunkInputStream; import org.apache.accumulo.examples.simple.filedata.FileDataIngest;
2 duplicated blocks of code must be removed.
import org.apache.accumulo.cloudtrace.instrument.Span; import org.apache.accumulo.cloudtrace.thrift.RemoteSpan; import org.apache.accumulo.cloudtrace.thrift.SpanReceiver;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.test.randomwalk.image; 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 (name.equals(new String(data))) zk.recursiveDelete(path, NodeMissingPolicy.SKIP);
Remove this call to "exit" or ensure it is really required.
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
2 duplicated blocks of code must be removed.
UNSUPPORTED_OPERATION(10), INVALID_TOKEN(11); case 11: return INVALID_TOKEN;
Immediately return this expression instead of assigning it to the temporary variable "ret".
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; import org.apache.accumulo.core.client.security.tokens.NullToken;
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.
* 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.
1 duplicated blocks of code must be removed.
if (paths.size() > 0) { long bulkTime = Long.MIN_VALUE; if (setTime) { for (DataFileValue dfv : paths.values()) { long nextTime = tabletTime.getAndUpdateTime(); if (nextTime < bulkTime) throw new IllegalStateException("Time went backwards unexpectedly " + nextTime + " " + bulkTime); bulkTime = nextTime; dfv.setTime(bulkTime); } } synchronized (timeLock) { if (bulkTime > persistedTime) persistedTime = bulkTime; MetadataTable.updateTabletDataFile(tid, extent, abs2rel(paths), tabletTime.getMetadataValue(persistedTime), auths, tabletServer.getLock()); }
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
import org.apache.accumulo.core.client.security.tokens.PasswordToken; conn = inst.getConnector("user", new PasswordToken("pass"));
Rename "connector" which hides the field declared at line 67.
exec(TestMultiTableIngest.class, args("--count", "" + ROWS, "-u", "root", "-i", instance, "-z", keepers, "-p", ROOT_PASSWORD)); exec(TestMultiTableIngest.class, args("--count", "" + ROWS, "--readonly", "-u", "root", "-i", instance, "-z", keepers, "-p", ROOT_PASSWORD));
Use "Integer.toString" instead.
ChunkInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "test", new Authorizations("A", "B", "C", "D")); ChunkInputFormat.setMockInstance(job.getConfiguration(), "instance1"); ChunkInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "test", new Authorizations("A", "B", "C", "D")); ChunkInputFormat.setMockInstance(job.getConfiguration(), "instance2"); ChunkInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "test", new Authorizations("A", "B", "C", "D")); ChunkInputFormat.setMockInstance(job.getConfiguration(), "instance3");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* @return The results of a query
Either log or rethrow this exception.
import org.apache.accumulo.server.fs.VolumeManager; public Repo<Master> call(long tid, Master master) throws Exception { VolumeManager fs = master.getFileSystem(); TabletOperations.createTabletDirectory(fs, tableInfo.tableId, null); public void undo(long tid, Master master) throws Exception { VolumeManager fs = master.getFileSystem(); for(String dir : ServerConstants.getTablesDirs()) { fs.deleteRecursively(new Path(dir + "/" + tableInfo.tableId)); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import com.google.common.net.HostAndPort; private void getZooLock(HostAndPort addr) throws KeeperException, InterruptedException { if (lock.tryLock(lockWatcher, new ServerServices(addr.toString(), Service.GC_CLIENT).toString().getBytes())) { private HostAndPort startStatsService() throws UnknownHostException { HostAndPort result = HostAndPort.fromParts(opts.getAddress(), port);
Remove this unused method parameter "threadName".
/* * 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.
String test = new String("test".getBytes(), encoding);
Remove this unused method parameter "ex".
import org.apache.accumulo.core.security.tokens.SecurityToken;
Replace all tab characters in this file by sequences of white-spaces.
package org.apache.accumulo.cloudtrace.instrument;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.thrift.AuthInfo; Connector conn = WalkingSecurity.get(state).getSystemConnector(); AuthInfo auth; target = WalkingSecurity.get(state).getTabUserName(); auth = WalkingSecurity.get(state).getTabAuthInfo(); target = WalkingSecurity.get(state).getSysUserName(); auth = WalkingSecurity.get(state).getSysAuthInfo(); boolean exists = WalkingSecurity.get(state).userExists(target); // Copy so if failed it doesn't mess with the password stored in state byte[] password = Arrays.copyOf(WalkingSecurity.get(state).getUserPassword(target), WalkingSecurity.get(state).getUserPassword(target).length); boolean hasPermission = WalkingSecurity.get(state).canAskAboutUser(auth, target);
Reduce this switch case number of lines from 44 to at most 5, for example by extracting code into methods.
private boolean preDelegate; if (preDelegate) cl = new VFSClassLoader(files, vfs, parent.getClassLoader()); else cl = new PostDelegatingVFSClassLoader(files, vfs, parent.getClassLoader()); public AccumuloReloadingVFSClassLoader(String uris, FileSystemManager vfs, ReloadingClassLoader parent, long monitorDelay, boolean preDelegate) throws FileSystemException { this.preDelegate = preDelegate; if (preDelegate) cl = new VFSClassLoader(files, vfs, parent.getClassLoader()); else cl = new PostDelegatingVFSClassLoader(files, vfs, parent.getClassLoader()); public AccumuloReloadingVFSClassLoader(String uris, FileSystemManager vfs, final ReloadingClassLoader parent, boolean preDelegate) throws FileSystemException { this(uris, vfs, parent, DEFAULT_TIMEOUT, preDelegate);
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. */ private Logger log; private Level level; private long t1; private long opid; private static AtomicLong nextOpid = new AtomicLong(); public OpTimer(Logger log, Level level) { this.log = log; this.level = level; } public OpTimer start(String msg) { opid = nextOpid.getAndIncrement(); if (log.isEnabledFor(level)) log.log(level, "tid=" + Thread.currentThread().getId() + " oid=" + opid + " " + msg); t1 = System.currentTimeMillis(); return this; } public void stop(String msg) { if (log.isEnabledFor(level)) { long t2 = System.currentTimeMillis(); String duration = String.format("%.3f secs", (t2 - t1) / 1000.0); msg = msg.replace("%DURATION%", duration); log.log(level, "tid=" + Thread.currentThread().getId() + " oid=" + opid + " " + msg); } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public void visit(State state, Properties props) throws Exception {
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.util.PeekingIterator;
Either log or rethrow this exception.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ this(Trace.currentTrace(), impl);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.junit.Assert; final String[] args = new String[] {"--fake", "-u", "root", "-p", ""};
Remove this unused private "appendProp" method.
import java.util.ArrayList; import java.util.List; import org.apache.accumulo.core.cli.BatchWriterOpts; import org.apache.accumulo.core.cli.ClientOnRequiredTable; import com.beust.jcommander.Parameter; static class Opts extends ClientOnRequiredTable { @Parameter(names="--partitions", required=true, description="the number of shards to create") int partitions; @Parameter(required=true, description="<file> { <file> ... }") List<String> files = new ArrayList<String>(); Opts opts = new Opts(); BatchWriterOpts bwOpts = new BatchWriterOpts(); opts.parseArgs(Index.class.getName(), args, bwOpts); BatchWriter bw = opts.getConnector().createBatchWriter(opts.tableName, bwOpts.getBatchWriterConfig()); for (String filename : opts.files) { index(opts.partitions, new File(filename), splitRegex, bw);
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. */
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.
disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output"); noWrapOpt = new Option("nw", "no-wrap", false, "disable wrapping of output");
Replace all tab characters in this file by sequences of white-spaces.
@Deprecated @Deprecated
Remove this unused private "appendProp" method.
@Override public String getName() { return "?"; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; serverSideIteratorList, serverSideIteratorOptions, iterEnv, false));
Remove this unused method parameter "extent".
TabletLocation tabLoc = TabletLocator.getLocator(instance, table).locateTablet(new Text(m.getRow()), false, true, credentials); TabletLocator.getLocator(instance, table).invalidateCache(tabLoc.tablet_extent); TabletLocator.getLocator(instance, table).invalidateCache(tabLoc.tablet_extent);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@Override public void visit(final State state, Properties props) throws Exception { Setup.run(state, new Runnable() { @Override public void run() { try { runLater(state); } catch (Throwable ex) { log.error(ex, ex); } } }); } abstract protected void runLater(State state) throws Exception;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.data.thrift.TCMResult; import org.apache.accumulo.core.data.thrift.TConditionalMutation; import org.apache.accumulo.core.data.thrift.TConditionalSession; import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException; @Override public TConditionalSession startConditionalUpdate(TInfo tinfo, TCredentials credentials, List<ByteBuffer> authorizations, String tableID) throws ThriftSecurityException, TException { return null; } @Override public List<TCMResult> conditionalUpdate(TInfo tinfo, long sessID, Map<TKeyExtent,List<TConditionalMutation>> mutations, List<String> symbols) throws NoSuchScanIDException, TException { return null; } @Override public void invalidateConditionalUpdate(TInfo tinfo, long sessID) throws TException {} @Override public void closeConditionalUpdate(TInfo tinfo, long sessID) throws TException {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
ByteBuffer _elem52; // required Range _elem55; // required ScanColumn _elem58; // required IteratorSetting _elem61; // required ByteBuffer _elem72; // required Range _elem75; // required ScanColumn _elem78; // required IteratorSetting _elem81; // required
Remove this unused method parameter "table".
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.tokens.PasswordToken;
1 duplicated blocks of code must be removed.
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
import org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException; TabletLocationState tls = null; try { tls = new TabletLocationState(extent, null, instance, null, null, false); } catch (BadLocationStateException e) { log.error("Unexpected error ", e); }
Either log or rethrow this exception.
package org.apache.accumulo.core.iterators.filter; import java.util.Collections; import java.util.Map; import java.util.Map.Entry; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.OptionDescriber; import org.apache.accumulo.core.iterators.conf.ColumnToClassMapping; import org.apache.accumulo.core.iterators.conf.PerColumnIteratorConfig; @SuppressWarnings("deprecation") public class ColumnAgeOffFilter implements Filter, OptionDescriber { private class TTLSet extends ColumnToClassMapping<Long> { public TTLSet(Map<String, String> objectStrings) { super(); for (Entry<String, String> entry : objectStrings.entrySet()) { String column = entry.getKey(); String ttl = entry.getValue(); Long l = Long.parseLong(ttl); PerColumnIteratorConfig ac = PerColumnIteratorConfig.decodeColumns(column, ttl); if(ac.getColumnQualifier() == null){ addObject(ac.getColumnFamily(), l); }else{ addObject(ac.getColumnFamily(), ac.getColumnQualifier(), l); } } } } TTLSet ttls; long currentTime = 0; @Override public boolean accept(Key k, Value v) { Long threshold = ttls.getObject(k); if (threshold == null) return true; if (currentTime - k.getTimestamp() > threshold) return false; return true; } @Override public void init(Map<String, String> options) { this.ttls = new TTLSet(options); currentTime = System.currentTimeMillis(); } public void overrideCurrentTime(long ts) { this.currentTime = ts; } @Override public IteratorOptions describeOptions() { return new IteratorOptions("colageoff","time to live in milliseconds for each column", null, Collections.singletonList("<columnName> <Long>")); } @Override public boolean validateOptions(Map<String, String> options) { this.ttls = new TTLSet(options); return true; } }
Return empty string instead.
m.put(Constants.METADATA_DATAFILE_COLUMN_FAMILY, new Text(filename), new Value(value.getBytes()));
Remove this unused method parameter "ex".
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper; public void initializeSecurity(InstanceTokenWrapper itw, String rootuser) throws AccumuloSecurityException {
Immediately return this expression instead of assigning it to the temporary variable "ret".
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
@Override public void unableToMonitorLockNode(final Throwable e) { Halt.halt(-1, new Runnable() { @Override public void run() { log.fatal("No longer able to monitor master lock node", e); } }); }
Remove this call to "exit" or ensure it is really required.
import java.io.File; result.value.mutations = Arrays.asList((Mutation[]) fileExtentMutation); TemporaryFolder root = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.thrift.TCredentials; private final TCredentials credentials; public TabletServerBatchReaderIterator(Instance instance, TCredentials credentials, String table, Authorizations authorizations, ArrayList<Range> ranges, ResultReceiver receiver, List<Column> columns, TCredentials credentials, ScannerOptions options, Authorizations authorizations, AccumuloConfiguration conf) ResultReceiver receiver, List<Column> columns, TCredentials credentials, ScannerOptions options, Authorizations authorizations, AccumuloConfiguration conf,
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.test.randomwalk.bulk; import org.apache.accumulo.test.randomwalk.State;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.iterators.user.GrepIterator;
Remove this unused private "match" 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. */
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.
exec("merge --all", true); exec("merge --all -t !METADATA");
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.
/* * 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.
List<TabletStats> onlineTabletsForTable = client.getTabletStats(Tracer.traceInfo(), SystemCredentials.get().toThrift(configuration.getInstance()), tableId);
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
import org.apache.accumulo.cloudtrace.instrument.Span; import org.apache.accumulo.cloudtrace.instrument.Trace;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
AccumuloConfiguration aconf = getConfiguration().getConfiguration(); RecoverLease impl = createInstanceFromPropertyName(aconf, Property.MASTER_LEASE_RECOVERY_IMPLEMETATION, RecoverLease.class, new RecoverLease()); impl.init(host, filename); fate.seedTransaction(tid, impl, true);
Rename the "log" logger to comply with the format "LOG(?:GER)?".
if (!shellState.getReader().getTerminal().isANSISupported()) throw new IOException("Terminal does not support ANSI commands");
Remove this call to "exit" or ensure it is really required.
@SuppressWarnings("deprecation")
6 duplicated blocks of code must be removed.
import java.util.ArrayList; import java.util.List; import org.apache.accumulo.core.cli.ClientOnRequiredTable; import com.beust.jcommander.Parameter; public static class Opts extends ClientOnRequiredTable { @Parameter(names="--vis", description="use a given visibility for the new counts", converter=VisibilityConverter.class) ColumnVisibility visibility = new ColumnVisibility(); @Parameter(names="--chunk", description="size of the chunks used to store partial files") int chunkSize = 64*1024; @Parameter(description="<file> { <file> ... }") List<String> files = new ArrayList<String>(); } public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(FileDataIngest.class.getName(), args); Connector conn = opts.getConnector(); if (!conn.tableOperations().exists(opts.tableName)) { conn.tableOperations().create(opts.tableName); conn.tableOperations().attachIterator(opts.tableName, new IteratorSetting(1, ChunkCombiner.class)); BatchWriter bw = conn.createBatchWriter(opts.tableName, opts.getBatchWriterConfig()); FileDataIngest fdi = new FileDataIngest(opts.chunkSize, opts.visibility); for (String filename : opts.files) { fdi.insertFileData(filename, bw); opts.stopTracing();
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.core.iterators.user.GrepIterator;
Remove this unused private "match" method.
import org.apache.accumulo.server.cli.ClientOpts; import com.beust.jcommander.Parameter; public static void checkTable(String tablename, TreeSet<KeyExtent> tablets, Opts opts) { if (broke && opts.fix) { MetadataTable.updateTabletPrevEndRow(ke, opts.getAuthInfo()); public static void checkMetadataTableEntries(Opts opts, FileSystem fs) throws Exception { if (opts.offline) { scanner = new OfflineMetadataScanner(ServerConfiguration.getSystemConfiguration(opts.getInstance()), fs); scanner = opts.getConnector().createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS); checkTable(entry2.getKey(), entry2.getValue(), opts); if (opts.fix) { Writer t = MetadataTable.getMetadataTable(opts.getAuthInfo()); checkTable(entry.getKey(), entry.getValue(), opts); static class Opts extends ClientOpts { @Parameter(names="--fix", description="best-effort attempt to fix problems found") boolean fix = false; @Parameter(names="--offline", description="perform the check on the files directly") boolean offline = false; Opts opts = new Opts(); opts.parseArgs(CheckForMetadataProblems.class.getName(), args); checkMetadataTableEntries(opts, fs); opts.stopTracing();
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. */
Override "equals(Object obj)" to comply with the contract of the "compareTo(T o)" 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. */ return getMetadataTableDir() + ZROOT_TABLET;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (tls.getState(onlineTabletServers()).equals(TabletState.HOSTED)) { if (tls.chopped) return TabletGoalState.UNASSIGNED; } else { if (tls.chopped && tls.walogs.isEmpty()) return TabletGoalState.UNASSIGNED; } return TabletGoalState.HOSTED; return TabletGoalState.UNASSIGNED;
Define a constant instead of duplicating this literal "Waiting for " 5 times.
/** * A Combiner that interprets Values as Longs and returns the largest Long among them. */
Remove the literal "true" boolean value.
package org.apache.accumulo.test.randomwalk.image; import org.apache.accumulo.test.randomwalk.Fixture; import org.apache.accumulo.test.randomwalk.State;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
import org.apache.accumulo.server.fs.VolumeManager; public MultiReader(VolumeManager fs, Path directory) throws IOException { for (FileStatus child : fs.listStatus(directory)) { FileSystem ns = fs.getFileSystemByPath(child.getPath()); heap.add(new Index(new Reader(ns, child.getPath().toString(), ns.getConf())));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.