Diff stringlengths 10 2k | Message stringlengths 28 159 |
|---|---|
import java.nio.charset.Charset;
private static final Charset utf8 = Charset.forName("UTF8");
cutPoints.add(new Text(Base64.decodeBase64(in.nextLine().getBytes(utf8)))); | Move this variable to comply with Java Code Conventions. |
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema;
Map<String,String> map = new HashMap<String,String>();
@Test(timeout = 120 * 1000)
for (int i = 0; i < 500000; i += 500000 / 59) {
@Override
s.fetchColumnFamily(MetadataSchema.TabletsSection.TabletColumnFamily.NAME);
s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
for (@SuppressWarnings("unused")
Entry<Key,Value> entry : s) | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.accumulo.core.cli;
import com.beust.jcommander.Parameter;
public class ScannerOpts {
@Parameter(names="--scanBatchSize", description="the number of key-values to pull during a scan")
public int scanBatchSize = 1000;
} | Remove this unused private "appendProp" method. |
package org.apache.accumulo.start.classloader.vfs.providers;
import org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.server.util.MetadataTableUtil;
import org.apache.accumulo.server.util.MetadataTableUtil.LogEntry;
Iterator<LogEntry> iterator = MetadataTableUtil.getLogEntries(SecurityConstants.getSystemCredentials()); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; | Move this constructor to comply with Java Code Conventions. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
/*
* 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.
*/ | 296 duplicated blocks of code must be removed. |
if (zooTabletStateStore != null && !flushed)
break; | Remove this call to "exit" or ensure it is really required. |
assertTrue(plan.inputFiles.isEmpty());
assertEquals(3, plan.inputFiles.size());
assertEquals(2, plan.inputFiles.size());
assertEquals(3, plan.inputFiles.size());
assertEquals(asStringSet(plan.inputFiles), asSet("file1,file2,file3".split(","))); | Replace this if-then-else statement by a single return statement. |
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
GENERAL_CLASSPATHS(AccumuloClassLoader.CLASSPATH_PROPERTY_NAME, AccumuloClassLoader.ACCUMULO_CLASSPATH_VALUE, PropertyType.STRING,
GENERAL_DYNAMIC_CLASSPATHS(AccumuloVFSClassLoader.DYNAMIC_CLASSPATH_PROPERTY_NAME, AccumuloVFSClassLoader.DEFAULT_DYNAMIC_CLASSPATH_VALUE,
PropertyType.STRING,
VFS_CLASSLOADER_SYSTEM_CLASSPATH_PROPERTY(AccumuloVFSClassLoader.VFS_CLASSLOADER_SYSTEM_CLASSPATH_PROPERTY, "", PropertyType.STRING,
"Configuration for a system level vfs classloader. Accumulo jar can be configured here and loaded out of HDFS."),
VFS_CONTEXT_CLASSPATH_PROPERTY(AccumuloVFSClassLoader.VFS_CONTEXT_CLASSPATH_PROPERTY, null, PropertyType.PREFIX, "Classpath for this context"); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/**
* A demonstration of reading entire rows and deleting entire rows.
*/ | Replace this use of System.out or System.err by a logger. |
private static final String PASSWORD = PREFIX + ".password";
conf.set(PASSWORD, new String(Base64.encodeBase64(passwd)));
ArrayList<String> rangeStrings = new ArrayList<String>(ranges.size());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
r.write(new DataOutputStream(baos));
rangeStrings.add(new String(Base64.encodeBase64(baos.toByteArray())));
} catch (IOException ex) {
throw new IllegalArgumentException("Unable to encode ranges to Base64", ex);
conf.setStrings(RANGES, rangeStrings.toArray(new String[0]));
* Gets the password from the configuration. WARNING: The password is stored in the Configuration and shared with all MapReduce tasks; It is BASE64 encoded to
* provide a charset safe conversion to a string, and is not intended to be secure.
protected static byte[] getPassword(Configuration conf) {
return Base64.decodeBase64(conf.get(PASSWORD, "").getBytes());
protected static TabletLocator getTabletLocator(Configuration conf) throws TableNotFoundException {
for (String rangeString : conf.getStringCollection(RANGES)) {
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(rangeString.getBytes()));
Range range = new Range();
range.readFields(new DataInputStream(bais));
ranges.add(range);
AccumuloException, AccumuloSecurityException { | 1 duplicated blocks of code must be removed. |
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
setACLs(zoo, ZooUtil.getRoot(instance), ZooUtil.getRoot(instance) + Constants.ZUSERS);
private void setACLs(IZooReaderWriter zoo, String root, String users) throws Exception {
Stat stat = new Stat();
List<ACL> acls = zoo.getZooKeeper().getACL(root, stat);
if (acls.equals(ZooDefs.Ids.OPEN_ACL_UNSAFE)) {
if (root.startsWith(users)) {
zoo.getZooKeeper().setACL(root, ZooUtil.PRIVATE, -1);
} else {
zoo.getZooKeeper().setACL(root, ZooUtil.PUBLIC, -1);
}
for (String child : zoo.getChildren(root)) {
setACLs(zoo, root + "/" + child, users);
}
}
}
| Remove the literal "true" boolean value. |
if (range == null)
return; | Remove this call to "exit" or ensure it is really required. |
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class DeleteRowsIT extends MacTest {
private static final Logger log = Logger.getLogger(DeleteRowsIT.class);
@Test
public void test() throws Exception { | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
shellState.getConnector().securityOperations().createUser(user, password.getBytes()); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.security.tokens.AccumuloToken;
private AccumuloToken<?,?> token = new UserPassToken("", "");
protected void setToken(AccumuloToken<?,?> token) {
this.token = token;
protected AccumuloToken<?,?> getToken() {
return token;
return getInstance().getConnector(getToken());
return new InstanceTokenWrapper(getToken(), getInstance().getInstanceID());
fTest.setToken(opts.getAccumuloToken()); | Return empty string instead. |
package org.apache.accumulo.server.logger;
public enum LogEvents {
//DO NOT CHANGE ORDER OF ENUMS, ORDER IS USED IN SERIALIZATION
OPEN,
DEFINE_TABLET,
MUTATION,
MANY_MUTATIONS,
COMPACTION_START,
COMPACTION_FINISH;
} | Return empty string instead. |
import org.apache.accumulo.core.security.tokens.PasswordToken; | Replace all tab characters in this file by sequences of white-spaces. |
package org.apache.accumulo.server.test.randomwalk.concurrent;
import java.util.List;
import java.util.Properties;
import java.util.Random;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.server.test.randomwalk.State;
import org.apache.accumulo.server.test.randomwalk.Test;
public class CreateTable extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
Random rand = (Random) state.get("rand");
@SuppressWarnings("unchecked")
List<String> tableNames = (List<String>) state.get("tables");
String tableName = tableNames.get(rand.nextInt(tableNames.size()));
try {
conn.tableOperations().create(tableName);
log.debug("Created table "+tableName);
} catch (TableExistsException e) {
log.debug("Create "+tableName+" failed, it exist");
}
}
} | Return empty string instead. |
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
if (cl.getArgs()[0].equalsIgnoreCase("on")) {
} else if (cl.getArgs()[0].equalsIgnoreCase("off")) {
} else {
}
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
final Token debug_command = new Token(getName()); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
ENTRIES((short)4, "entries");
private BitSet __isset_bit_vector = new BitSet(1);
int entries)
oprot.writeBitSet(optionals, 4);
BitSet incoming = iprot.readBitSet(4); | Remove this unused method parameter "timestamp". |
if (super.validateOptions(options) == false)
return false;
try {
this.ttls = new TTLSet(options);
} catch (Exception e) {
throw new IllegalArgumentException("bad TTL options", e);
} | Remove the literal "false" boolean value. |
import java.util.SortedSet;
import java.util.TreeSet;
SortedSet<String> ecfs = new TreeSet<String>(); | Either log or rethrow this exception. |
package org.apache.accumulo.trace.instrument;
import org.apache.accumulo.trace.instrument.impl.NullSpan;
import org.apache.accumulo.trace.instrument.impl.RootMilliSpan;
import org.apache.accumulo.trace.instrument.receivers.SpanReceiver;
import org.apache.accumulo.trace.thrift.TInfo; | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
if (args.length != 2) {
System.err.println("Usage CreateRandomRFile <filename> <size>");
System.exit(-1);
} | Remove this unused private "appendProp" method. |
static void setLocation(TServers tservers, String server, KeyExtent tablet, KeyExtent ke, String location, String instance) {
if (instance == null)
instance = "";
Key lk = new Key(mr, Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY, new Text(instance));
static void setLocation(TServers tservers, String server, KeyExtent tablet, KeyExtent ke, String location) {
setLocation(tservers, server, tablet, ke, location, "");
}
public void testAccumulo1248() throws Exception {
TServers tservers = new TServers();
TabletLocatorImpl metaCache = createLocators(tservers, "tserver1", "tserver2", "foo");
KeyExtent ke1 = nke("foo", null, null);
// set two locations for a tablet, this is not supposed to happen. The metadata cache should throw an exception if it sees this rather than caching one of
// the locations.
setLocation(tservers, "tserver2", MTE, ke1, "L1", "I1");
setLocation(tservers, "tserver2", MTE, ke1, "L2", "I2");
try {
metaCache.locateTablet(new Text("a"), false, false, credential);
assertTrue(false);
} catch (Exception e) {
}
} | Remove this unused method parameter "retry". |
* @param auth
* An AuthInfo object. | 1 duplicated blocks of code must be removed. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.core.security.ColumnVisibility;
private static final ColumnVisibility EMPTY_VIS = new ColumnVisibility();
Mutation m = ContinuousIngest.genMutation(rowLong, random.nextInt(max_cf), random.nextInt(max_cq), EMPTY_VIS, iiId, count++, key.getRowData()
.toArray(), random, | Remove this unused method parameter "r". |
import org.apache.accumulo.core.client.IteratorSetting;
/**
* @deprecated since 1.4 {@link #attachIterator(String, IteratorSetting)}
*/ | Either log or rethrow this exception. |
import org.apache.accumulo.core.client.security.SecurityErrorCode; | Do not forget to remove this deprecated code someday. |
import java.util.concurrent.TimeUnit;
scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
| 3 duplicated blocks of code must be removed. |
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.security.thrift.SecurityErrorCode;
public static ByteBuffer wrapper(SecurityToken token) throws AccumuloSecurityException {
// Cannot get typing right to get both warnings resolved. Open to suggestions.
@SuppressWarnings({"rawtypes", "unchecked"})
private static byte[] getBytes(SecurityToken token) throws AccumuloSecurityException {
SecuritySerDe serDe = token.getSerDe();
WritableUtils.writeCompressedString(out, serDe.getClass().getCanonicalName());
WritableUtils.writeCompressedByteArray(out, serDe.serialize(token));
public static String asBase64String(SecurityToken token2) throws AccumuloSecurityException {
public static SecurityToken fromBase64String(String token) throws AccumuloSecurityException {
private static SecurityToken fromBytes(byte[] token) throws AccumuloSecurityException {
SecuritySerDe<?> serDe = (SecuritySerDe<?>) Class.forName(clazz).newInstance();
return serDe.deserialize(WritableUtils.readCompressedByteArray(in));
log.error(e);
throw new AccumuloSecurityException("unknown user", SecurityErrorCode.INVALID_TOKEN);
log.error(e);
throw new AccumuloSecurityException("unknown user", SecurityErrorCode.INVALID_TOKEN);
log.error(e);
throw new AccumuloSecurityException("unknown user", SecurityErrorCode.INVALID_TOKEN);
}
public static SecurityToken unwrap(ByteBuffer token) throws AccumuloSecurityException { | Either log or rethrow this exception. |
public ChunkInputStream getData(String hash) throws IOException { | Either log or rethrow this exception. |
import org.apache.accumulo.core.security.tokens.SecurityToken;
* @deprecated Use {@link #createUser(SecurityToken)} instead
* @deprecated Use {@link #createUser(SecurityToken)} instead
public void createUser(final SecurityToken newToken, final Authorizations authorizations) throws AccumuloException, AccumuloSecurityException {
public void createUser(final SecurityToken newToken) throws AccumuloException, AccumuloSecurityException {
* @deprecated since 1.5, use {@link #authenticateUser(SecurityToken)}
public boolean authenticateUser(final SecurityToken token2) throws AccumuloException, AccumuloSecurityException {
public void changeUserPassword(final SecurityToken newToken) throws AccumuloException, AccumuloSecurityException { | Either log or rethrow this exception. |
import org.apache.accumulo.core.security.tokens.AuthenticationToken; | 1 duplicated blocks of code must be removed. |
if (client != null)
close(client);
if (client != null)
close(client); | Remove this call to "exit" or ensure it is really required. |
context = contexts.get(contextName); | Return empty string instead. |
protected static void generateDocumentation(PrintStream doc) {
| Move the "/docs/config.html" string literal on the left side of this string comparison. |
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; | Move this constructor to comply with Java Code Conventions. |
public static native int lockMemoryPages(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.server.cli.ClientOpts;
ClientOpts opts = new ClientOpts();
opts.parseArgs(LocalityCheck.class.getName(), args);
Connector connector = opts.getConnector(); | 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.
*/
public class NoTableCommand extends Command {
private Option tableOpt;
@Override
public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
shellState.setTableName("");
return 0;
}
@Override
public String description() {
return "returns to a tableless shell state";
}
public String usage() {
return getName();
}
@Override
public int numArgs() {
return 0;
}
public Options getOptions() {
Options o = new Options();
tableOpt = new Option(Shell.tableOption, "tableName", true, "Returns to a no table state");
o.addOption(tableOpt);
return o;
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
@SuppressWarnings("all") public class TColumn implements org.apache.thrift.TBase<TColumn, TColumn._Fields>, java.io.Serializable, Cloneable { | 13 duplicated blocks of code must be removed. |
public static void printMetaBlockInfo(Configuration conf, FileSystem fs, Path path) throws Exception {
FSDataInputStream fsin = fs.open(path);
BCFile.Reader bcfr = new BCFile.Reader(fsin, fs.getFileStatus(path).getLen(), conf);
Set<Entry<String,MetaIndexEntry>> es = bcfr.metaIndex.index.entrySet();
for (Entry<String,MetaIndexEntry> entry : es) {
PrintStream out = System.out;
out.println("Meta block : " + entry.getKey());
out.println(" Raw size : " + String.format("%,d", entry.getValue().getRegion().getRawSize()) + " bytes");
out.println(" Compressed size : " + String.format("%,d", entry.getValue().getRegion().getCompressedSize()) + " bytes");
out.println(" Compression type : " + entry.getValue().getCompressionAlgorithm().getName());
out.println();
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
@SuppressWarnings("deprecation")
FileSystem fs = FileUtil.getFileSystem(conf, AccumuloConfiguration.getSiteConfiguration());
Path path = new Path(args[0]);
printMetaBlockInfo(conf, fs, path);
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
if (ba.length > Long.SIZE / Byte.SIZE)
throw new IllegalArgumentException("Byte array of size " + ba.length + " is too big to hold a long"); | Remove this call to "exit" or ensure it is really required. |
if (!shellState.getConnector().securityOperations().authenticateUser(currentUser, new PasswordToken(oldPassword)))
shellState.getConnector().securityOperations().changeLocalUserPassword(user, new PasswordToken(pass)); | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
ByteBuffer _elem2; // optional
ByteBuffer _elem7; // optional | 277 duplicated blocks of code must be removed. |
permHandle.cleanUser(user); | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
ByteBuffer _elem28; // required
ScanColumn _elem31; // required
IteratorSetting _elem34; // required
ByteBuffer _elem43; // required
ScanColumn _elem46; // required
IteratorSetting _elem49; // required | Remove this unused method parameter "table". |
return new ActiveCompaction(compactor.extent.toThrift(), System.currentTimeMillis() - compactor.startTime, new ArrayList<String>(
compactor.filesToCompact.keySet()), compactor.outputFile, type, reason, localityGroup, entriesRead, entriesWritten, iiList, iterOptions); | 15 duplicated blocks of code must be removed. |
import org.apache.accumulo.start.classloader.AccumuloClassLoader;
import org.apache.commons.vfs2.impl.VFSClassLoader;
Whitebox.setInternalState(AccumuloVFSClassLoader.class, "loader", (AccumuloReloadingVFSClassLoader) null);
Whitebox.setInternalState(AccumuloClassLoader.class, "SITE_CONF", new File(defaultDir.getPath() + "/conf/accumulo-site.xml").toURI().toURL().toString());
Assert.assertTrue((acl instanceof AccumuloReloadingVFSClassLoader));
Assert.assertTrue((acl.getParent() instanceof URLClassLoader));
Whitebox.setInternalState(AccumuloVFSClassLoader.class, "loader", (AccumuloReloadingVFSClassLoader) null);
Whitebox.setInternalState(AccumuloClassLoader.class, "SITE_CONF", new File(defaultDir.getPath() + "/conf/accumulo-site.xml").toURI().toURL().toString());
Assert.assertTrue((acl.getParent() instanceof VFSClassLoader));
VFSClassLoader arvcl = (VFSClassLoader) acl.getParent();
Assert.assertEquals(1, arvcl.getFileObjects().length);
Assert.assertTrue(arvcl.getFileObjects()[0].getURL().toString().contains("/accumulo/classpath/HelloWorld.jar")); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import java.util.concurrent.atomic.AtomicInteger;
private static final AtomicInteger tableCounter = new AtomicInteger(0);
private static String makeTableName() {
return "test" + tableCounter.getAndIncrement();
}
final String table = makeTableName();
final String TABLE_TEST = makeTableName();
final String TABLE_TEST = makeTableName();
final String TABLE_TEST = makeTableName();
final String TABLE_TEST = makeTableName();
final String TABLE_TEST = makeTableName();
final String TABLE_TEST = makeTableName();
final String TABLE_TEST = makeTableName();
final String TABLE_TEST2 = makeTableName();
client.cloneTable(creds, TABLE_TEST, TABLE_TEST2, true, null, null);
scanner = client.createScanner(creds, TABLE_TEST2, null);
client.deleteTable(creds, TABLE_TEST2);
client.cloneTable(creds, TABLE_TEST, TABLE_TEST2, true, null, null);
tablesToScan.add(TABLE_TEST2);
client.compactTable(creds, TABLE_TEST2, null, null, null, true, true);
client.deleteTable(creds, TABLE_TEST2);
String scid = client.createScanner(creds, table, new ScanOptions());
final String TABLE_TEST = makeTableName();
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.proxy.thrift.AccumuloProxy;
final long maxFrameSize = AccumuloConfiguration.getMemoryInBytes(properties.getProperty("maxFrameSize", "16M"));
if (maxFrameSize > Integer.MAX_VALUE)
throw new RuntimeException(maxFrameSize + " is larger than MAX_INT");
args.transportFactory(new TFramedTransport.Factory((int)maxFrameSize)); | Define and throw a dedicated exception instead of using a generic one. |
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
private Map<String,String> names = new HashMap<String,String>();
return ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZLOGGERS;
synchronized public Map<String,String> getLoggersFromZooKeeper() {
Map<String,String> current = new HashMap<String,String>();
if (value != null) current.put(child, new String(value));
Map<String,String> current = getLoggersFromZooKeeper();
for (Entry<String,String> entry : current.entrySet()) | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
public FileSystem getImplementation() {
return impl;
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
@Override
public void close() {
// Nothing needs to be closed
} | Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. |
package org.apache.accumulo.examples.wikisearch.aggregator;
import org.apache.accumulo.examples.wikisearch.aggregator.GlobalIndexUidAggregator;
import org.apache.accumulo.examples.wikisearch.protobuf.Uid;
import org.apache.accumulo.examples.wikisearch.protobuf.Uid.List.Builder; | 2 duplicated blocks of code must be removed. |
holdtime(60000, false, 1, "Hold Time"),
allavg(1, false, 100, "Overall Avg", true),
allmax(1, false, 100, "Overall Max", true);
private boolean derived;
this(max, adjustMax, significance, description, false);
}
private StatType(int max, boolean adjustMax, float significance, String description, boolean derived) {
this.derived = derived;
public boolean isDerived() {
return derived;
}
public static int numDerived() {
int count = 0;
for (StatType st : StatType.values())
if (st.isDerived())
count++;
return count;
}
motion = StatType.allmax;
color = StatType.allavg;
spacing = 40;
else if (size.equals("20"))
spacing = 20;
sb.append("var numNormalStats = ").append(StatType.values().length - StatType.numDerived()).append(";\n"); | Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'. |
/**
private static final long serialVersionUID = 1L;
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.security.Authorizations;
BatchScanner bs = conn.createBatchScanner(tableName, Authorizations.EMPTY, 3); | Remove this unused method parameter "range". |
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum { | 300 duplicated blocks of code must be removed. |
import java.io.File;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.minicluster.MiniAccumuloInstance;
private static File folder;
private static MiniAccumuloCluster cluster = null;
public static synchronized void setUp() throws Exception {
if (getInstanceOneConnector() == null && cluster == null) {
folder = createSharedTestDir(SimpleMacIT.class.getName());
MiniAccumuloConfig cfg = new MiniAccumuloConfig(folder, ROOT_PASSWORD);
cleanUp(cluster);
@Override
public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
Connector conn = getInstanceOneConnector();
return conn == null ? cluster.getConnector("root", ROOT_PASSWORD) : conn;
}
public String rootPath() {
return (getInstanceOneConnector() == null ? cluster.getConfig().getDir() : getInstanceOnePath()).getAbsolutePath();
private static Connector getInstanceOneConnector() {
try {
return new MiniAccumuloInstance("instance1", getInstanceOnePath()).getConnector("root", new PasswordToken(ROOT_PASSWORD));
} catch (Exception e) {
return null;
}
}
private static File getInstanceOnePath() {
return new File(System.getProperty("user.dir") + "/accumulo-maven-plugin/instance1");
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import java.util.EnumSet;
import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
conn.tableOperations().checkIteratorConflicts(t, null, EnumSet.allOf(IteratorScope.class)); | Remove this unused method parameter "table". |
if (value != null)
current.put(child, new String(value)); | Remove this call to "exit" or ensure it is really required. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
import java.nio.ByteBuffer;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.security.tokens.AuthenticationToken;
private TCredentials credentials;
public SecurityOperationsImpl(Instance instance, TCredentials credentials) {
createUser(user, new PasswordToken(password));
changeUserAuthorizations(user, authorizations);
@Override
public void createUser(final String principal, final AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
_createUser(principal, token);
private void _createUser(final String principal, final AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
ArgumentChecker.notNull(principal, token);
client.createLocalUser(Tracer.traceInfo(), credentials, principal, ByteBuffer.wrap(((PasswordToken) token).getPassword()));
client.dropLocalUser(Tracer.traceInfo(), credentials, user);
* @deprecated see {@link #authenticateUser(String, AuthenticationToken)}
@Deprecated
return authenticateUser(principal, new PasswordToken(token));
public boolean authenticateUser(final String principal, final AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
final TCredentials toAuth = CredentialHelper.create(principal, token, instance.getInstanceID());
@Override
changeLoginInfo(principal, new PasswordToken(token));
public void changeLoginInfo(final String principal, final AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
final TCredentials toChange = CredentialHelper.create(principal, token, instance.getInstanceID());
client.changeLocalUserPassword(Tracer.traceInfo(), credentials, principal, ByteBuffer.wrap(((PasswordToken) token).getPassword()));
return client.listLocalUsers(Tracer.traceInfo(), credentials); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
public class BatchWriterFlushIT extends SimpleMacIT {
String bwft = makeTableName();
c.tableOperations().create(bwft);
String bwlt = makeTableName();
c.tableOperations().create(bwlt);
runFlushTest(bwft);
runLatencyTest(bwlt);
private void runLatencyTest(String tableName) throws Exception {
BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig().setMaxLatency(1000, TimeUnit.MILLISECONDS));
Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
private void runFlushTest(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException, Exception {
BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
* @since 1.5.0
| Move this constructor to comply with Java Code Conventions. |
Option rowOpt = new Option("r", "row", true, "search for a specific row");
Option maxOpt = new Option("m", "max-mutations", true, "the maximum number of mutations to print per log entry");
Option tabletOpt = new Option("t", "tablet", true, "key extent");
Option rowPatternOpt = new Option("p", "row-pattern", true, "search for a row that matches the given regex"); | Reduce this switch case number of lines from 8 to at most 5, for example by extracting code into methods. |
@Deprecated | Remove this unused method parameter "ex". |
/**
* @deprecated since 1.4
* @use org.apache.accumulo.core.iterators.Combiner
*/ | Either log or rethrow this exception. |
log.info("Checking if Zookeeper is available. If this hangs, then you need to make sure zookeeper is running");
if (!zookeeperAvailable()) {
log.fatal("Zookeeper needs to be up and running in order to init. Exiting ...");
return false;
}
/**
* @return
*/
private static boolean zookeeperAvailable() {
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
try {
return zoo.exists("/");
} catch (KeeperException e) {
return false;
} catch (InterruptedException e) {
return false;
}
}
| Either log or rethrow this exception. |
import org.apache.accumulo.mini.MiniAccumuloCluster; | This block of commented-out lines of code should be removed. |
import org.apache.accumulo.core.util.shell.commands.AddAuthsCommand;
import org.apache.accumulo.core.util.shell.commands.ListCompactionsCommand;
import org.apache.accumulo.core.util.shell.commands.PingCommand;
Command[] debuggingCommands = {new ClasspathCommand(), new DebugCommand(), new ListScansCommand(), new ListCompactionsCommand(), new TraceCommand(),
new PingCommand()};
Command[] userCommands = {new AddAuthsCommand(), new CreateUserCommand(), new DeleteUserCommand(), new DropUserCommand(), new GetAuthsCommand(), new PasswdCommand(), | Return empty string instead. |
package org.apache.accumulo.examples.wikisearch.logic;
import org.apache.accumulo.examples.wikisearch.logic.AbstractQueryLogic;
import org.apache.accumulo.examples.wikisearch.logic.QueryLogic;
import org.apache.accumulo.examples.wikisearch.parser.RangeCalculator;
import org.apache.accumulo.examples.wikisearch.sample.Document;
import org.apache.accumulo.examples.wikisearch.sample.Field;
import org.apache.accumulo.examples.wikisearch.sample.Results; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
private RowIterator decisionIterator;
private static class RowIterator extends WrappingIterator {
private Range rowRange;
private boolean hasTop;
RowIterator(SortedKeyValueIterator<Key,Value> source) {
super.setSource(source);
}
void setRow(Range row) {
this.rowRange = row;
}
@Override
public boolean hasTop() {
return hasTop && super.hasTop();
}
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
range = rowRange.clip(range, true);
if (range == null) {
hasTop = false;
} else {
hasTop = true;
super.seek(range, columnFamilies, inclusive);
}
}
}
Range rowRange = new Range(row);
decisionIterator.setRow(rowRange);
decisionIterator.seek(rowRange, columnFamilies, inclusive);
this.decisionIterator = new RowIterator(source.deepCopy(env)); | Introduce a new variable instead of reusing the parameter "range". |
/*
* 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. |
TableInfo _val3; // required | Remove this call to "exit" or ensure it is really required. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.accumulo.minicluster;
public class ProcessNotFoundException extends Exception {
private static final long serialVersionUID = 1L;
} | 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");
return Base64.decodeBase64(conf.get(PASSWORD, "").getBytes(utf8)); | Move this variable to comply with Java Code Conventions. |
if (testList.size() != 2 || testList.get(0) != 0l || testList.get(1) != 1l) {
* Class<? extends Encoder<List<Long>>> specifying the encoding type. | Remove the literal "false" boolean value. |
import org.apache.accumulo.core.security.thrift.SecurityErrorCode;
import org.apache.accumulo.core.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.security.tokens.PasswordToken; | 1 duplicated blocks of code must be removed. |
import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.thrift.Credential;
import org.apache.accumulo.core.security.thrift.tokens.PasswordToken;
Credential credentials = getCredentials();
public Credential getCredentials() {
return CredentialHelper.createSquelchError(username, new PasswordToken().setPassword(password.getBytes()), this.getInstance().getInstanceID()); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
return Base64.decodeBase64(conf.get(PASSWORD, "").getBytes()); | Remove this unused method parameter "ex". |
import org.apache.accumulo.core.security.tokens.SecurityToken;
public ConnectorImpl(Instance instance, final SecurityToken token2) throws AccumuloException, AccumuloSecurityException { | Either log or rethrow this exception. |
public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
throw new TableNotFoundException(tableName, tableName, "");
public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
new TableNotFoundException(tableName, tableName, ""); | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
}
*
final StringBuilder sb = new StringBuilder(key.length() + v.getSize() * 5);
| 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.
*/
public class NoOpNormalizer implements Normalizer {
public String normalizeFieldValue(String field, Object value) {
return value.toString();
} | Immediately return this expression instead of assigning it to the temporary variable "r". |
shellState.getReader().println("Removed "+pluginType+" on " + tableName);
shellState.getReader().println(ent.getKey() + ": " + ent.getValue()); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.security.tokens.PasswordToken; | Replace all tab characters in this file by sequences of white-spaces. |
package org.apache.accumulo.server.test.randomwalk.sequential;
import java.util.Properties;
import org.apache.accumulo.server.test.randomwalk.State;
import org.apache.accumulo.server.test.randomwalk.Test;
public class Commit extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
state.getMultiTableBatchWriter().flush();
log.debug("Committed "+state.getInteger("numWrites")+" writes. Total writes: "+state.getInteger("totalWrites"));
state.set("numWrites", new Integer(0));
}
} | Return empty string instead. |
package org.apache.accumulo.test.randomwalk.shard;
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. |
package org.apache.accumulo.server.test.randomwalk.multitable;
import java.util.ArrayList;
import java.util.Properties;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.server.test.randomwalk.State;
import org.apache.accumulo.server.test.randomwalk.Test;
public class CreateTable extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
int nextId = ((Integer) state.get("nextId")).intValue();
String tableName = String.format("%s_%d", state.getString("tableNamePrefix"), nextId);
try {
conn.tableOperations().create(tableName);
String tableId = Tables.getNameToIdMap(state.getInstance()).get(tableName);
log.debug("created "+ tableName+" (id:"+tableId+")");
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
tables.add(tableName);
} catch (TableExistsException e) {
log.warn("Failed to create "+tableName+" as it already exists");
}
nextId++;
state.set("nextId", new Integer(nextId));
}
} | Return empty string instead. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.