Diff
stringlengths
10
2k
Message
stringlengths
28
159
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
Move this constructor to comply with Java Code Conventions.
public static void addLogEntry(AuthInfo credentials, LogEntry entry, ZooLock zooLock) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
tsStats.addAll(client.getTabletStats(Tracer.traceInfo(), SecurityConstants.getSystemCredentials(), tableId)); historical = client.getHistoricalStats(Tracer.traceInfo(), SecurityConstants.getSystemCredentials());
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
EXPORT(11), COMPACT_CANCEL(12); case 12: return COMPACT_CANCEL;
Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-z0-9]*)*$'.
import org.apache.accumulo.core.security.tokens.UserPassToken; Connector conn = mi.getConnector(new UserPassToken("", ""));
Either log or rethrow this exception.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
private static final String PREFIX = AccumuloRowInputFormatTest.class.getSimpleName(); private static final String INSTANCE_NAME = PREFIX + "_mapreduce_instance"; private static final String TEST_TABLE_1 = PREFIX + "_mapreduce_table_1"; AccumuloRowInputFormat.setMockInstance(job, INSTANCE_NAME); final MockInstance instance = new MockInstance(INSTANCE_NAME); conn.tableOperations().create(TEST_TABLE_1); writer = conn.createBatchWriter(TEST_TABLE_1, new BatchWriterConfig()); MRTester.main(new String[] {"root", "", TEST_TABLE_1});
Either log or rethrow this exception.
public class AddSplitIT extends SimpleMacIT { String tableName = makeTableName(); c.tableOperations().create(tableName); insertData(tableName, 1l); c.tableOperations().addSplits(tableName, splits); Collection<Text> actualSplits = c.tableOperations().listSplits(tableName); verifyData(tableName, 1l); insertData(tableName, 2l); c.tableOperations().addSplits(tableName, splits); actualSplits = c.tableOperations().listSplits(tableName); verifyData(tableName, 2l); private void verifyData(String tableName, long ts) throws Exception { Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY); private void insertData(String tableName, long ts) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException { BatchWriter bw = getConnector().createBatchWriter(tableName, null);
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. */ @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * @param args */ public static void main(String[] args) throws Exception { FileSystem fs = FileSystem.get(new Configuration()); Instance instance = HdfsZooInstance.getInstance(); Connector conn = instance.getConnector("root", "secret"); org.apache.accumulo.core.util.TableDiskUsage.printDiskUsage(ServerConfiguration.getSystemConfiguration(), Arrays.asList(args), fs, conn); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; public class VersioningIteratorTest { @Test @Test VersioningIterator it = new VersioningIterator(); IteratorSetting is = new IteratorSetting(1, VersioningIterator.class); VersioningIterator.setMaxVersions(is, 3); it.init(new SortedMapIterator(tm), is.getProperties(), null); @Test @Test @Test @Test public void test6() throws IOException { Text colf = new Text("a"); Text colq = new Text("b"); TreeMap<Key,Value> tm = new TreeMap<Key,Value>(); createTestData(tm, colf, colq); VersioningIterator it = new VersioningIterator(); IteratorSetting is = new IteratorSetting(1, VersioningIterator.class); VersioningIterator.setMaxVersions(is, 3); it.init(new SortedMapIterator(tm), is.getProperties(), null); VersioningIterator it2 = it.deepCopy(null); Key seekKey = new Key(new Text(String.format("%03d", 1)), colf, colq, 19); it.seek(new Range(seekKey, false, null, true), EMPTY_COL_FAMS, false); it2.seek(new Range(seekKey, false, null, true), EMPTY_COL_FAMS, false); assertTrue(it.hasTop()); assertTrue(it.getTopKey().getTimestamp() == 18); assertTrue(it2.hasTop()); assertTrue(it2.getTopKey().getTimestamp() == 18); }
Define and throw a dedicated exception instead of using a generic one.
if (client.tableExists(creds, TABLE_TEST)) client.deleteTable(creds, TABLE_TEST); client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS); String scanner = client.createScanner(creds, TABLE_TEST, null); assertFalse(client.hasNext(scanner)); client.closeScanner(scanner); try { client.hasNext(scanner); fail("exception not thrown"); } catch (UnknownScanner us) {} try { client.closeScanner(scanner); fail("exception not thrown"); } catch (UnknownScanner us) {} if (client.tableExists(creds, TABLE_TEST)) client.deleteTable(creds, TABLE_TEST); client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS); String writer = client.createWriter(creds, TABLE_TEST, null); client.update(writer, mutation("row0", "cf", "cq", "value")); client.flush(writer); client.update(writer, mutation("row2", "cf", "cq", "value2")); client.closeWriter(writer); // this is a oneway call, so it does not throw exceptions client.update(writer, mutation("row2", "cf", "cq", "value2")); try { client.flush(writer); fail("exception not thrown"); } catch (UnknownWriter uw) {}
Either log or rethrow this exception.
package org.apache.accumulo.test.functional;
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. */
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
MockTable(boolean limitVersion, TimeType timeType) { settings = IteratorUtil.generateInitialTableProperties(limitVersion);
Either log or rethrow this exception.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.minicluster; import java.io.File; import java.net.MalformedURLException; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.ZooKeeperInstance; import org.apache.accumulo.core.conf.Property; import org.apache.hadoop.conf.Configuration; /** * */ public class MiniAccumuloInstance extends ZooKeeperInstance { /** * Construct an {@link Instance} entry point to Accumulo using a {@link MiniAccumuloCluster} directory */ public MiniAccumuloInstance(String instanceName, File directory) { super(instanceName, getZooKeepersFromDir(directory)); } private static String getZooKeepersFromDir(File directory) { if (!directory.isDirectory()) throw new IllegalArgumentException("Not a directory " + directory.getPath()); File configFile = new File(new File(directory, "conf"), "accumulo-site.xml"); Configuration conf = new Configuration(false); try { conf.addResource(configFile.toURI().toURL()); } catch (MalformedURLException e) { throw new IllegalStateException("Missing file: " + configFile.getPath()); } return conf.get(Property.INSTANCE_ZK_HOST.getKey()); } }
Remove this hard-coded password.
package org.apache.accumulo.server.master.tserverOps; import java.net.InetSocketAddress; import org.apache.accumulo.core.tabletserver.thrift.MutationLogger; import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.core.util.ThriftUtil; import org.apache.accumulo.server.conf.ServerConfiguration; import org.apache.accumulo.server.fate.Repo; import org.apache.accumulo.server.master.Master; import org.apache.accumulo.server.master.tableOps.MasterRepo; import org.apache.accumulo.server.security.SecurityConstants; import org.apache.log4j.Logger; public class StopLogger extends MasterRepo { private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(StopLogger.class); private String logger; public StopLogger(String logger) { this.logger = logger; } @Override public long isReady(long tid, Master environment) throws Exception { return 0; } @Override public Repo<Master> call(long tid, Master m) throws Exception { InetSocketAddress addr = AddressUtil.parseAddress(logger, 0); MutationLogger.Iface client = ThriftUtil.getClient(new MutationLogger.Client.Factory(), addr, ServerConfiguration.getSystemConfiguration()); try { client.halt(null, SecurityConstants.getSystemCredentials()); log.info("logger asked to halt " + logger); } catch (Exception ex) { log.error("Unable to talk to logger at " + addr); } finally { ThriftUtil.returnClient(client); } return null; } @Override public void undo(long tid, Master m) throws Exception { } }
Return empty string instead.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
@Test(timeout = 2 * 60 * 1000)
Replace this use of System.out or System.err by a logger.
import org.apache.accumulo.core.util.MetadataTable; import org.apache.accumulo.core.util.RootTable; Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY); range = new Range(new Key(first).followingKey(PartialKey.ROW), false, RootTable.KEYSPACE.getEndKey(), false); log.debug("hole in " + MetadataTable.NAME);
Use "Long.toString" instead.
if (f.matches("^accumulo-core-.+jar$") || f.matches("^accumulo-server-.+jar$") || f.matches("^accumulo-fate-.+jar$") || f.matches("^accumulo-trace-.+jar$")
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
300 duplicated blocks of code must be removed.
import org.apache.hadoop.fs.FileSystem; final FileSystem fs; MockAccumulo(FileSystem fs) { this.fs = fs; } public FileSystem getFileSystem() { return fs; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** import org.apache.accumulo.fate.util.UtilWaitThread; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; public class ZooReaderWriter extends org.apache.accumulo.fate.zookeeper.ZooReaderWriter { super(string, timeInMillis, auth);
Remove this call to "exit" or ensure it is really required.
package org.apache.accumulo.test.functional; * $ ./bin/accumulo accumulo.test.functional.RunTests --tests /user/hadoop/tests --output /user/hadoop/results
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
return new ZooKeeperInstance(getInstanceName(), ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_ZK_HOST));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ private int size; private ArrayList<Object> row; TableRow(int size) { this.size = size; this.row = new ArrayList<Object>(size); } public boolean add(Object obj) { if (row.size() == size) throw new IllegalStateException("Row is full."); return row.add(obj); } Object get(int index) { return row.get(index); } int size() { return row.size(); } Object set(int i, Object value) { return row.set(i, value); } public static <T> Comparator<TableRow> getComparator(int index, Comparator<T> comp) { return new TableRowComparator<T>(index, comp); } private static class TableRowComparator<T> implements Comparator<TableRow> { private int index; private Comparator<T> comp; public TableRowComparator(int index, Comparator<T> comp) { this.index = index; this.comp = comp; } @SuppressWarnings("unchecked") @Override public int compare(TableRow o1, TableRow o2) { return comp.compare((T) o1.get(index), (T) o2.get(index)); } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.cloudtrace.instrument.Trace;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* * * * * * * * *
Replace all tab characters in this file by sequences of white-spaces.
Map<String,String> config = parseConfig(Property.TABLE_CONSTRAINT_PREFIX + "1=org.apache.accumulo.examples.simple.constraints.NumericValueConstraint", Property.TABLE_CONSTRAINT_PREFIX + "2=org.apache.accumulo.examples.simple.constraints.AlphaNumKeyConstraint"); if (!cvs.constrainClass.equals("org.apache.accumulo.examples.simple.constraints.NumericValueConstraint")) { expected.put("org.apache.accumulo.examples.simple.constraints.NumericValueConstraint", numericErrors); expected.put("org.apache.accumulo.examples.simple.constraints.AlphaNumKeyConstraint", 1);
Move the "org.apache.accumulo.examples.simple.constraints.NumericValueConstraint" string literal on the left side of this string comparison.
statsIterator = new StatsIterator(multiIter, TabletServer.seekCount, scannedCount);
Move this variable to comply with Java Code Conventions.
if (data != null) data.close();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public String putEphemeralData(String zPath, byte[] data) throws KeeperException, InterruptedException { return ZooUtil.putEphemeralData(getZooKeeper(), zPath, data); } @Override
Move this variable to comply with Java Code Conventions.
String[] tableNames = getTableNames(2); String table = tableNames[0]; String table2 = tableNames[1];
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.cloudtrace.instrument.TraceExecutorService;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.client.BatchWriterConfig; return instance.getConnector(auths).createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig().setMaxMemory(MAX_MEMORY).setMaxLatency(LATENCY, TimeUnit.MILLISECONDS).setMaxWriteThreads(THREADS));
Remove this unused method parameter "e".
String tableName = OptUtil.getTableOpt(cl, shellState);
Either log or rethrow this exception.
@Deprecated
Return empty string instead.
opts.putAll(si.getOptions());
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
import org.apache.accumulo.core.client.BatchWriterConfig; BatchWriter bw = conn.createBatchWriter("table1", new BatchWriterConfig());
Remove this unused method parameter "e".
IS_CONFIGURED, PRINCIPAL, TOKEN, } private static enum TokenSource { FILE, INLINE; private String prefix; private TokenSource() { prefix = name().toLowerCase() + ":"; } public String prefix() { return prefix; } conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), TokenSource.INLINE.prefix() + token.getClass().getName() + ":" + Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(token))); * the path to the token file in DFS conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), TokenSource.FILE.prefix() + tokenFile); * Gets the authenticated token from either the specified token file or directly from the configuration, whichever was used when the job was configured. * @return the principal's authentication token * @see #setConnectorInfo(Class, Configuration, String, String) public static AuthenticationToken getAuthenticationToken(Class<?> implementingClass, Configuration conf) { String token = conf.get(enumToConfKey(implementingClass, ConnectorInfo.TOKEN)); if (token == null || token.isEmpty()) return null; if (token.startsWith(TokenSource.INLINE.prefix())) { String[] args = token.substring(TokenSource.INLINE.prefix().length()).split(":", 2); if (args.length == 2) return AuthenticationTokenSerializer.deserialize(args[0], Base64.decodeBase64(args[1].getBytes(Constants.UTF8))); } else if (token.startsWith(TokenSource.FILE.prefix())) { String tokenFileName = token.substring(TokenSource.FILE.prefix().length()); return getTokenFromFile(conf, getPrincipal(implementingClass, conf), tokenFileName); } throw new IllegalStateException("Token was not properly serialized into the configuration"); private static AuthenticationToken getTokenFromFile(Configuration conf, String principal, String tokenFile) { return creds.getToken();
This block of commented-out lines of code should be removed.
private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(StopLogger.class); private String logger; public StopLogger(String logger) { this.logger = logger; } @Override public long isReady(long tid, Master environment) throws Exception { return 0; } @Override public Repo<Master> call(long tid, Master m) throws Exception { InetSocketAddress addr = AddressUtil.parseAddress(logger, 0); MutationLogger.Iface client = ThriftUtil.getClient(new MutationLogger.Client.Factory(), addr, ServerConfiguration.getSystemConfiguration()); try { client.halt(null, SecurityConstants.getSystemCredentials()); log.info("logger asked to halt " + logger); } catch (Exception ex) { log.error("Unable to talk to logger at " + addr); } finally { ThriftUtil.returnClient(client); return null; } @Override public void undo(long tid, Master m) throws Exception {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.util.Collections; /** * Provides an immutable view of a list of byte buffers, representing the same bytes. This does not protect against modifying the underlying byte arrays. */ public static List<ByteBuffer> toImmutableByteBufferList(Collection<byte[]> bytesList) { if (bytesList == null) return null; ArrayList<ByteBuffer> result = new ArrayList<ByteBuffer>(); for (byte[] bytes : bytesList) { result.add(ByteBuffer.wrap(bytes)); } return Collections.unmodifiableList(result); }
Return an empty collection instead of null.
/* * 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.
public class RowDeleteIT extends ConfigurableMacIT {
Use "Integer.toString" instead.
import org.apache.accumulo.server.ServerOpts; import org.apache.accumulo.server.util.TServerUtils.ServerAddress; private int startServer(AccumuloConfiguration conf, String address, Property portHint, TProcessor processor, String threadName) throws UnknownHostException { ServerAddress sp = TServerUtils.startServer(conf, address, portHint, processor, this.getClass().getSimpleName(), threadName, Property.TSERV_PORTSEARCH, return sp.address.getPort(); int port = startServer(getSystemConfiguration(), clientAddress.getHostName(), Property.TSERV_CLIENTPORT, processor, "Thrift Client Server"); clientAddress = new InetSocketAddress(clientAddress.getHostName(), clientPort); return clientAddress.getHostName() + ":" + clientAddress.getPort(); ServerOpts opts = new ServerOpts(); opts.parseArgs("tserver", args); String hostname = opts.getAddress();
Remove this unused method parameter "threadName".
@Parameter(names = {"-f", "--force"}, description = "force the given server to stop by removing its lock") @Parameters(commandDescription = "stop the tablet server on the given hosts") @Parameter(description = "<host> {<host> ... }") @Parameters(commandDescription = "stop the master") static class StopMasterCommand {} @Parameters(commandDescription = "stop all the servers") static class StopAllCommand {} log.error(e, e); log.error(e, e); private static void stopServer(Instance instance, final TCredentials credentials, final boolean tabletServersToo) throws AccumuloException, AccumuloSecurityException { private static void stopTabletServer(Instance instance, final TCredentials creds, List<String> servers, final boolean force) throws AccumuloException, AccumuloSecurityException {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@Override public long getReadaheadThreshold() { return 0l; } @Override public void setReadaheadThreshold(long batches) { }
Move this constructor to comply with Java Code Conventions.
* @return The given key's row * @return The given key's dataLocation * @return The given key's term * @return The given key's DocID * @return The given key's UID * @return The top Key for a given TermSource
1 duplicated blocks of code must be removed.
package org.apache.accumulo.cloudtrace.instrument; import org.apache.accumulo.cloudtrace.instrument.CountSampler;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
lrfi.init(new ColumnFamilySkippingIterator(smi), is.getOptions(), new RowDeletingIteratorTest.TestIE(scope, false));
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. */
Replace all tab characters in this file by sequences of white-spaces.
boolean isInitialized; isInitialized = true; } /** * Creates an uninitialized instance. This should be used in conjunction with {@link #initialize(Iterator)}. */ public PeekingIterator() { isInitialized = false; } /** * Initializes this iterator, to be used with {@link #PeekingIterator()}. */ public PeekingIterator<E> initialize(Iterator<E> source) { this.source = source; if (source.hasNext()) top = source.next(); else top = null; isInitialized = true; return this; if (!isInitialized) throw new IllegalStateException("Iterator has not yet been initialized"); @Override if (!isInitialized) throw new IllegalStateException("Iterator has not yet been initialized"); @Override if (!isInitialized) throw new IllegalStateException("Iterator has not yet been initialized");
Return empty string instead.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
private static final Logger log = Logger.getLogger(DeadServerList.class); private final String path; public DeadServerList(String path) { this.path = path; ZooReaderWriter zoo = ZooReaderWriter.getInstance(); try { zoo.mkdirs(path); } catch (Exception ex) { log.error("Unable to make parent directories of " + path, ex); } public List<DeadServer> getList() { List<DeadServer> result = new ArrayList<DeadServer>(); ZooReaderWriter zoo = ZooReaderWriter.getInstance(); try { List<String> children = zoo.getChildren(path); if (children != null) { for (String child : children) { Stat stat = new Stat(); byte[] data = zoo.getData(path + "/" + child, stat); DeadServer server = new DeadServer(child, stat.getMtime(), new String(data)); result.add(server); } } catch (Exception ex) { log.error(ex, ex); return result; } public void delete(String server) { ZooReaderWriter zoo = ZooReaderWriter.getInstance(); try { zoo.recursiveDelete(path + "/" + server, NodeMissingPolicy.SKIP); } catch (Exception ex) { log.error(ex, ex); } public void post(String server, String cause) { ZooReaderWriter zoo = ZooReaderWriter.getInstance(); try { zoo.putPersistentData(path + "/" + server, cause.getBytes(), NodeExistsPolicy.SKIP); } catch (Exception ex) { log.error(ex, ex); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.client.IteratorSetting; /** * @deprecated since 1.4 {@link #attachIterator(String, IteratorSetting)} */
1 duplicated blocks of code must be removed.
final String tia = String.format("--rfile %s/mf%05d --timestamp 1 --size 50 --random 56 --rows %d --start %d --user root", opts.outputDirectory, count, currEnd - currStart, currStart);
Define a constant instead of duplicating this literal "tmp/testmf" 4 times.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); lst.add(s.getBytes(utf8));
Move this variable to comply with Java Code Conventions.
String path = ZooUtil.getRoot(master.getInstance()) + Constants.ZTSERVERS + "/" + server.getLocation(); path = ZooUtil.getRoot(master.getInstance()) + Constants.ZDEADTSERVERS + "/" + server.getLocation();
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.
if (iterInfo.priority > max) max = iterInfo.priority; if (entry.getValue() == null) continue; if (options == null) options = Collections.emptyMap();
Remove this call to "exit" or ensure it is really required.
if (status.last.finished > 0) gcActivity.addRow("File&nbsp;Collection,&nbsp;Last&nbsp;Cycle", status.last.finished, status.last.candidates, status.last.deleted, status.last.inUse, status.last.errors, status.last.finished - status.last.started); if (status.current.started > 0) gcActivity.addRow("File&nbsp;Collection,&nbsp;Running", status.current.finished, status.current.candidates, status.current.deleted, status.current.inUse, status.current.errors, System.currentTimeMillis() - status.current.started); if (status.lastLog.finished > 0) gcActivity.addRow("WAL&nbsp;Collection,&nbsp;Last&nbsp;Cycle", status.lastLog.finished, status.lastLog.candidates, status.lastLog.deleted, status.lastLog.inUse, status.lastLog.errors, status.lastLog.finished - status.lastLog.started); if (status.currentLog.started > 0) gcActivity.addRow("WAL&nbsp;Collection,&nbsp;Running", status.currentLog.finished, status.currentLog.candidates, status.currentLog.deleted, status.currentLog.inUse, status.currentLog.errors, System.currentTimeMillis() - status.currentLog.started);
Remove this call to "exit" or ensure it is really required.
import java.util.TreeMap; public static class TokenConverter implements IStringConverter<AuthenticationToken> { private Map<String,String> tokenProperties = new TreeMap<String,String>();
Remove this hard-coded password.
/* * 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 (deleter == null) deleter = new Mutation(entry.getKey().getRow());
Remove this call to "exit" or ensure it is really required.
super.seek(range, EMPTY_SET, false); super.seek(range, EMPTY_SET, false);
At most one statement is allowed per line, but 2 statements were found on this line.
/* * 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.PasswordToken;
1 duplicated blocks of code must be removed.
AccumuloInputFormat.setConnectorInfo(job, user, pass.getBytes()); AccumuloOutputFormat.setConnectorInfo(job, user, pass.getBytes()); Connector c = mockInstance.getConnector("root", "");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.start.classloader.AccumuloClassLoader; } else if (args[0].equals("proxy")) { runTMP = AccumuloClassLoader.loadClass("org.apache.accumulo.proxy.Proxy");
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
log.warn("Failed to load table balancer class " + clazzName + " for table " + table, e); log.info("Loaded class " + clazzName + " for table " + table); log.warn("Failed to load table balancer class " + clazzName + " for table " + table, e); tops = configuration.getInstance().getConnector(SecurityConstants.getSystemCredentials()).tableOperations();
Return empty string instead.
public class RestartIT extends ConfigurableMacIT { "-u", "root", "-p", ROOT_PASSWORD, "-u", "root", "-p", ROOT_PASSWORD,
Use "Integer.toString" instead.
import org.apache.accumulo.server.cli.ClientOnRequiredTable; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.fs.VolumeManagerImpl; import org.apache.accumulo.trace.instrument.Tracer; VolumeManager fs = VolumeManagerImpl.get(); long length1 = 0, dcount1 = 0, fcount1 = 0; long length2 = 0, dcount2 = 0, fcount2 = 0; for (String dir : ServerConstants.getTablesDirs()) { ContentSummary contentSummary = fs.getContentSummary(new Path(dir)); length1 += contentSummary.getLength(); dcount1 += contentSummary.getDirectoryCount(); fcount1 += contentSummary.getFileCount(); contentSummary = fs.getContentSummary(new Path(dir, tableId)); length2 += contentSummary.getLength(); dcount2 += contentSummary.getDirectoryCount(); fcount2 += contentSummary.getFileCount(); } return "" + length1 + " " + dcount1 + " " + fcount1 + " " + length2 + " " + dcount2 + " " + fcount2;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.server.cli.ClientOpts; Scanner scanner = connector.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY);
Remove this unused method parameter "range".
import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily; scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME); scanner.fetchColumnFamily(DataFileColumnFamily.NAME); scanner.setRange(MetadataSchema.TabletsSection.getRange()); if (key.compareColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) { } else if (key.compareColumnFamily(DataFileColumnFamily.NAME) == 0) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.nio.charset.Charset; import org.apache.accumulo.core.security.CredentialHelper; import org.apache.accumulo.core.security.thrift.Credential; import org.apache.accumulo.core.security.thrift.tokens.PasswordToken; import org.apache.accumulo.core.security.thrift.tokens.SecurityToken; import org.apache.accumulo.trace.instrument.Trace; value = dfault.getBytes(Charset.forName("UTF-8")); public String principal = System.getProperty("user.name"); public SecurityToken getToken() { PasswordToken pt = new PasswordToken(); if (password.value == null) return null; return pt.setPassword(password.value); return pt.setPassword(securePassword.value); return getInstance().getConnector(this.principal, this.getToken()); public Credential getCredentials() throws AccumuloSecurityException { return CredentialHelper.create(principal, getToken(), getInstance().getInstanceID()); public void setAccumuloConfigs(Job job) throws AccumuloSecurityException {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.hadoop.mapreduce.Job; public static void setSplitFile(Job job, String file) { public static void setNumSubBins(Job job, int num) {
2 duplicated blocks of code must be removed.
@Override public void visit(State state, Properties props) throws Exception { String indexTableName = (String) state.get("indexTableName"); int numPartitions = (Integer) state.get("numPartitions"); Random rand = (Random) state.get("rand"); SortedSet<Text> splitSet = ShardFixture.genSplits(numPartitions, rand.nextInt(numPartitions) + 1, "%06x"); log.debug("adding splits " + indexTableName); state.getConnector().tableOperations().addSplits(indexTableName, splitSet); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (entry.getKey().toLowerCase().contains("password") || entry.getKey().toLowerCase().contains("secret"))
Return empty string instead.
package org.apache.accumulo.test.randomwalk.security; 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.
lookupResult.dataSize += kve.numBytes(); long dataSize = 0; LookupResult result = null; result = lookup(iter, ranges, columns, results, maxResultSize); return result; if (result != null) queryBytes += result.dataSize;
2 duplicated blocks of code must be removed.
import com.google.common.net.HostAndPort; TServerUtils.startTServer(HostAndPort.fromParts("0.0.0.0", opts.port), processor, "NullTServer", "null tserver", 2, 1000, 10 * 1024 * 1024); HostAndPort addr = HostAndPort.fromParts(InetAddress.getLocalHost().getHostName(), opts.port);
Remove this unused method parameter "threadName".
import org.apache.accumulo.core.client.security.tokens.PasswordToken; Connector conn = mi.getConnector("", new PasswordToken("")); Connector conn = mi.getConnector("", new PasswordToken("")); Connector conn = mi.getConnector("", new PasswordToken("")); Connector conn = mi.getConnector("", new PasswordToken("")); Connector conn = mi.getConnector("", new PasswordToken("")); Connector conn = mi.getConnector("", new PasswordToken("")); Connector conn = mi.getConnector("", new PasswordToken(""));
Rename "connector" which hides the field declared at line 67.
if (super.validateOptions(options) == false) return false; } catch (Exception e) { throw new IllegalArgumentException("bad long " + TTL + ":" + options.get(TTL));
Return empty string instead.
import org.apache.accumulo.server.cli.ClientOpts; import org.apache.accumulo.core.cli.BatchWriterOpts; import com.beust.jcommander.Parameter; public static class Opts extends ClientOpts { @Parameter(names="-update", description="Make changes to the !METADATA table to include missing files") boolean update = false; } * A utility to add files to the !METADATA table that are not listed in the root tablet. * This is a recovery tool for someone who knows what they are doing. It might be better to * save off files, and recover your instance by re-initializing and importing the existing files. * Opts opts = new Opts(); BatchWriterOpts bwOpts = new BatchWriterOpts(); opts.parseArgs(AddFilesWithMissingEntries.class.getName(), args, bwOpts); final Scanner scanner = opts.getConnector().createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS); final MultiTableBatchWriter writer = opts.getConnector().createMultiTableBatchWriter(bwOpts.getBatchWriterConfig()); count += addUnknownFiles(fs, directory, knownFiles, last, writer, opts.update); count += addUnknownFiles(fs, directory, knownFiles, last, writer, opts.update); private static int addUnknownFiles(FileSystem fs, String directory, Set<String> knownFiles, KeyExtent ke, MultiTableBatchWriter writer, boolean update) throws Exception { if (file.getPath().getName().endsWith("_tmp") || file.getPath().getName().endsWith("_tmp.rf")) continue; m.put(Constants.METADATA_DATAFILE_COLUMN_FAMILY, new Text(filename), new Value(value.getBytes()));
Remove this unused private "appendProp" method.
import java.nio.charset.Charset; import org.apache.accumulo.core.Constants; AccumuloInputFormat.setConnectorInfo(job, args[0], args[1].getBytes(Charset.forName("UTF-8"))); AccumuloInputFormat.setInputTableName(job, args[2]); AccumuloInputFormat.setScanAuthorizations(job, Constants.NO_AUTHS); AccumuloOutputFormat.setConnectorInfo(job, args[0], args[1].getBytes(Charset.forName("UTF-8"))); AccumuloOutputFormat.setCreateTables(job, true); AccumuloOutputFormat.setDefaultTableName(job, args[5]);
Either log or rethrow this exception.
import org.apache.accumulo.start.classloader.vfs.providers.ReadOnlyHdfsFileProvider;
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.NoVisFilter **/
Remove this unused private "match" method.
package org.apache.accumulo.test.functional;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
/** * This iterator facilitates document-partitioned indexing. It expects a table structure of the following form: * * row: shardID, colfam: term, colqual: docID * * When you configure this iterator with a set of terms (column families), it will return only the docIDs that appear with all of the specified terms. The * result will have an empty column family, as follows: * * row: shardID, colfam: (empty), colqual: docID * * This iterator is commonly used with BatchScanner or AccumuloInputFormat, to parallelize the search over all shardIDs. * * README.shard in docs/examples shows an example of using the IntersectingIterator. */ /** * to be made protected * * @param columns * @return encoded columns * @deprecated since 1.4 {@link #setColumnFamilies(IteratorSetting, Text[] columns)} */ /** * to be made protected * * @param flags * @return encoded flags * @deprecated since 1.4 {@link #setColumnFamilies(IteratorSetting, Text[] columns, boolean[] flags)} */ protected static Text[] decodeColumns(String columns) { /** * to be made protected * * @param flags * @return decoded flags * @deprecated since 1.4 */ /** * Encode columns and NOT flags indicating which columns should be negated (docIDs will be excluded if matching negated columns, instead of included). * * @param cfg * @param columns * @param notFlags */ public static void setColumnFamilies(IteratorSetting cfg, Text[] columns, boolean[] notFlags) { if (columns.length != notFlags.length) throw new IllegalArgumentException("columns and notFlags arrays must be the same length"); setColumnFamilies(cfg, columns); cfg.addOption(IntersectingIterator.notFlagOptionName, IntersectingIterator.encodeBooleans(notFlags)); } }
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
@SuppressWarnings("deprecation")
1 duplicated blocks of code must be removed.
import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.impl.TabletLocator; /** * Initializes an Accumulo {@link org.apache.accumulo.core.client.impl.TabletLocator} based on the configuration. * * @param job * the Hadoop job for the configured job * @return an Accumulo tablet locator * @throws org.apache.accumulo.core.client.TableNotFoundException * if the table name set on the job doesn't exist * @since 1.5.0 * @deprecated since 1.6.0 */ @Deprecated protected static TabletLocator getTabletLocator(JobConf job) throws TableNotFoundException { return InputConfigurator.getTabletLocator(CLASS, job, InputConfigurator.getInputTableName(CLASS, job)); } for (IteratorSetting iterator : iterators)
Do not forget to remove this deprecated code someday.
package org.apache.accumulo.cloudtrace.instrument;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); this(s.getBytes(utf8));
Move this variable to comply with Java Code Conventions.
import org.apache.accumulo.core.client.BatchWriterConfig; BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
Remove this unused method parameter "e".