Diff stringlengths 10 2k | Message stringlengths 28 159 |
|---|---|
return true; | Either log or rethrow this exception. |
if (valueString == null)
return defaultMinutes; | Remove this call to "exit" or ensure it is really required. |
String tableName = getTableNames(1)[0];
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.server.ServerConstants;
String dest = ServerConstants.getRecoveryDir() + "/" + child; | Make the "audit" logger private static final and rename it to comply with the format "LOG(?:GER)?". |
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
this(username, new MockAccumulo());
this.username = username;
this.acu = acu;
public BatchScanner createBatchScanner(String tableName, Authorizations authorizations, int numQueryThreads) throws TableNotFoundException {
public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, long maxMemory, long maxLatency,
int maxWriteThreads) throws TableNotFoundException {
return new MockBatchDeleter(acu, tableName, authorizations);
public BatchWriter createBatchWriter(String tableName, long maxMemory, long maxLatency, int maxWriteThreads) throws TableNotFoundException {
public Scanner createScanner(String tableName, Authorizations authorizations) throws TableNotFoundException {
if (table == null) throw new TableNotFoundException(tableName, tableName, "no such table");
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
String tableName = OptUtil.getTableOpt(cl, shellState);
switch (OptUtil.getAldOpt(cl)) { | Either log or rethrow this exception. |
import org.apache.accumulo.core.cli.Help;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.security.thrift.SecurityErrorCode;
import com.beust.jcommander.Parameter;
return new UpdateErrors(new HashMap<TKeyExtent,Long>(), new ArrayList<TConstraintViolationSummary>(), new HashMap<TKeyExtent, SecurityErrorCode>());
static class Opts extends Help {
@Parameter(names={"-i", "--instance"}, description="instance name", required=true)
String iname = null;
@Parameter(names={"-z", "--keepers"}, description="comma-separated list of zookeeper host:ports", required=true)
String keepers = null;
@Parameter(names="--table", description="table to adopt", required=true)
String tableName = null;
@Parameter(names="--port", description="port number to use")
int port = DefaultConfiguration.getInstance().getPort(Property.TSERV_CLIENTPORT);
}
Opts opts = new Opts();
opts.parseArgs(NullTserver.class.getName(), args);
TServerUtils.startTServer(opts.port, processor, "NullTServer", "null tserver", 2, 1000, 10*1024*1024);
InetSocketAddress addr = new InetSocketAddress(InetAddress.getLocalHost(), opts.port);
ZooKeeperInstance zki = new ZooKeeperInstance(opts.iname, opts.keepers);
String tableId = Tables.getTableId(zki, opts.tableName);
long randomSessionID = opts.port; | Remove this unused private "appendProp" method. |
import org.apache.accumulo.core.security.thrift.Credential;
public static void authenticate(Credential auth, State state, Properties props) throws Exception { | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
if (cred.getToken().isDestroyed())
throw new AccumuloSecurityException(cred.getPrincipal(), SecurityErrorCode.TOKEN_EXPIRED);
| Either log or rethrow this exception. |
package org.apache.accumulo.examples.wikisearch.ingest;
import org.apache.accumulo.examples.wikisearch.reader.AggregatingRecordReader;
aggregators.add(new AggregatorConfiguration(new Text("fi\0" + family), org.apache.accumulo.examples.wikisearch.aggregator.TextIndexAggregator.class.getName()));
tops.setProperty(indexTableName, stem, "19,org.apache.accumulo.examples.wikisearch.iterator.TotalAggregatingIterator");
tops.setProperty(indexTableName, stem + "*", "org.apache.accumulo.examples.wikisearch.aggregator.GlobalIndexUidAggregator");
tops.setProperty(reverseIndexTableName, stem, "19,org.apache.accumulo.examples.wikisearch.iterator.TotalAggregatingIterator");
tops.setProperty(reverseIndexTableName, stem + "*", "org.apache.accumulo.examples.wikisearch.aggregator.GlobalIndexUidAggregator");
conf.set("mapred.map.tasks.speculative.execution", "false");
| Rename "table" which hides the field declared at line 107. |
new DistributedWorkQueue(ZooUtil.getRoot(master.getInstance()) + Constants.ZRECOVERY).addWork(file, source.getBytes()); | Remove this unused private "appendProp" method. |
return listSplits(tableName);
}
@Override
public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
return listSplits(tableName);
}
@Override
public Collection<Text> listSplits(String tableName) throws TableNotFoundException {
public Collection<Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException {
return listSplits(tableName); | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
package org.apache.accumulo.examples.wikisearch.reader; | Rename "table" which hides the field declared at line 107. |
import org.apache.accumulo.core.client.admin.TableOperations;
TableOperations to = c.tableOperations();
to.create("test_ingest");
String id = to.tableIdMap().get("test_ingest");
to.delete("test_ingest");
assertNull(to.tableIdMap().get("test_ingest"));
to.create("test_ingest");
to.delete("test_ingest"); | 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]*$'. |
/*
* 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.metadata.MetadataTable;
ret = TabletLocator.getLocator(instance, new Text(tableId));
TabletLocator.getLocator(instance, new Text(table)).invalidateCache(location);
TabletLocator.getLocator(instance, new Text(entry.getKey().getTableId())).invalidateCache(entry.getKey());
TabletLocator.getLocator(instance, new Text(table)).invalidateCache(failedExtent); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
package org.apache.accumulo.test.randomwalk.bulk;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test; | Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison. |
import java.util.LinkedList;
import java.util.List;
@Override
public List<Set<AuthProperty>> getProperties() {
List<Set<AuthProperty>> toRet = new LinkedList<Set<AuthProperty>>();
Set<AuthProperty> internal = new TreeSet<AuthProperty>();
internal.add(new AuthProperty("password", "the password for the principal"));
toRet.add(internal);
return toRet;
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* 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 Batch nextBatch(SortedKeyValueIterator<Key,Value> iter, Range range, int num, Set<Column> columns) throws IOException {
Scanner createScanner(Range range, int num, Set<Column> columns, Authorizations authorizations, List<IterInfo> ssiList,
Set<Column> columnSet;
ScanOptions(int num, Authorizations authorizations, byte[] defaultLabels, Set<Column> columnSet, List<IterInfo> ssiList, | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
for (String dir : ServerConstants.getTablesDirs()) {
final Path path = new Path(dir + "/" + tableId + directory);
for (FileStatus file : fs.listStatus(path)) {
if (file.getPath().getName().endsWith("_tmp") || file.getPath().getName().endsWith("_tmp.rf"))
continue;
final String filename = directory + "/" + file.getPath().getName();
if (!knownFiles.contains(filename)) {
count++;
final Mutation m = new Mutation(row);
String size = Long.toString(file.getLen());
String entries = "1"; // lie
String value = size + "," + entries;
m.put(MetadataTable.DATAFILE_COLUMN_FAMILY, new Text(filename), new Value(value.getBytes()));
if (update) {
writer.getBatchWriter(MetadataTable.NAME).addMutation(m);
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.cli.BatchWriterOpts;
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(ContinuousIngest.class.getName(), args, bwOpts);
BatchWriter bw = conn.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig()); | Remove this unused method parameter "opts". |
import org.apache.accumulo.core.client.mock.MockInstance;
private static final String MOCK = ".useMockInstance";
public static void setMockInstance(JobContext job, String instanceName) {
Configuration conf = job.getConfiguration();
conf.setBoolean(INSTANCE_HAS_BEEN_SET, true);
conf.setBoolean(MOCK, true);
conf.set(INSTANCE_NAME, instanceName);
}
if (conf.getBoolean(MOCK, false))
return new MockInstance(conf.get(INSTANCE_NAME)); | Either log or rethrow this exception. |
@Test(timeout = 30 * 1000) | Either log or rethrow this exception. |
import org.apache.accumulo.server.iterators.MetadataBulkLoadFilter;
TablePropUtil.setTableProperty(Constants.METADATA_TABLE_ID, Property.TABLE_ITERATOR_PREFIX.getKey() + "majc.bulkLoadFilter", "20,"
+ MetadataBulkLoadFilter.class.getName());
| Either log or rethrow this exception. |
import org.apache.accumulo.core.security.tokens.PasswordToken; | Replace all tab characters in this file by sequences of white-spaces. |
@Deprecated | Return empty string instead. |
return Base64.decodeBase64(conf.get(PASSWORD, "").getBytes());
return authString == null ? Constants.NO_AUTHS : new Authorizations(authString.getBytes());
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(rangeString.getBytes()));
Text cf = new Text(idx < 0 ? Base64.decodeBase64(col.getBytes()) : Base64.decodeBase64(col.substring(0, idx).getBytes()));
Text cq = idx < 0 ? null : new Text(Base64.decodeBase64(col.substring(idx + 1).getBytes()));
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(itstring.getBytes())); | Remove this unused private "appendProp" method. |
public static final String COMMENT_PREFIX = "#";
if (input.startsWith(COMMENT_PREFIX)) {
return;
}
| Define a constant instead of duplicating this literal "Unknown command" 3 times. |
* <li>{@link AccumuloInputFormat#setConnectorInfo(JobConf, AccumuloToken)} OR {@link AccumuloInputFormat#setConnectorInfo(JobConf, Path)} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.client.TableNotFoundException;
private Option noFlushOption, waitOpt, profileOpt, cancelOpt;
private boolean cancel = false;
if (cancel) {
try {
shellState.getConnector().tableOperations().cancelCompaction(tableName);
Shell.log.info("Compaction canceled for table " + tableName);
} catch (TableNotFoundException e) {
throw new AccumuloException(e);
}
} else {
try {
if (wait) {
Shell.log.info("Compacting table ...");
}
shellState.getConnector().tableOperations().compact(tableName, startRow, endRow, iterators, flush, wait);
Shell.log.info("Compaction of table " + tableName + " " + (wait ? "completed" : "started") + " for given range");
} catch (Exception ex) {
throw new AccumuloException(ex);
if (cl.hasOption(cancelOpt.getLongOpt())) {
cancel = true;
if (cl.getOptions().length > 2) {
throw new IllegalArgumentException("Can not specify other options with cancel");
}
} else {
cancel = false;
}
cancelOpt = new Option(null, "cancel", false, "cancel user initiated compactions");
opts.addOption(cancelOpt);
| Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-z0-9]*)*$'. |
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; | Move this constructor to comply with Java Code Conventions. |
} else if (args[0].equals("rfile-info")) {
} else if (args[0].equals("login-info")) {
runTMP = cl.loadClass("org.apache.accumulo.core.util.LoginProperties"); | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
@SuppressWarnings("all") public class TabletMutations implements org.apache.thrift.TBase<TabletMutations, TabletMutations._Fields>, java.io.Serializable, Cloneable { | 13 duplicated blocks of code must be removed. |
import org.apache.accumulo.server.zookeeper.IZooReaderWriter;
IZooReaderWriter zk = ZooReaderWriter.getInstance(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import java.net.InetAddress;
import org.apache.accumulo.server.util.TServerUtils;
import org.apache.accumulo.server.util.TServerUtils.ServerPort;
ServerPort serverPort = TServerUtils.startTServer(port, new SpanReceiver.Processor(new Receiver()), "tracer", "tracer", 4, 1000l);
server = serverPort.server;
InetAddress address = Accumulo.getLocalAddress(args);
registerInZooKeeper(address.getHostAddress() + ":" + serverPort.port); | 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. |
package org.apache.accumulo.core.iterators.system;
import java.io.IOException;
import java.util.Map;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.IteratorEnvironment;
import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
import org.apache.accumulo.core.iterators.WrappingIterator;
public class CountingIterator extends WrappingIterator {
private long count;
public CountingIterator deepCopy(IteratorEnvironment env)
{
return new CountingIterator(this,env);
}
private CountingIterator(CountingIterator other, IteratorEnvironment env)
{
setSource(other.getSource().deepCopy(env));
count = 0;
}
public CountingIterator(SortedKeyValueIterator<Key, Value> source){
this.setSource(source);
count = 0;
}
@Override
public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) {
throw new UnsupportedOperationException();
}
@Override
public void next() throws IOException {
getSource().next();
count++;
}
public long getCount(){
return count;
}
} | Return empty string instead. |
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.file.FileSKVWriter;
import org.apache.accumulo.core.file.rfile.RFile;
import org.apache.accumulo.core.file.rfile.RFileOperations;
Key next() {
Key ret = nextKey[currentMin];
String outFile = String.format("%s/index_%04d", newDir, count++);
outFiles.add(new Path(outFile));
FileSKVWriter writer = new RFileOperations().openWriter(outFile, fs, conf, AccumuloConfiguration.getDefaultConfiguration());
writer.append(mii.next(), new Value(new byte[0]));
String newDir = String.format("%s/" + RFile.EXTENSION + "_%06d", dir, i);
FileSKVWriter writer = new RFileOperations().openWriter(newDir, fs, conf, AccumuloConfiguration.getDefaultConfiguration());
writer.append(key, new Value(new byte[0])); | Either log or rethrow this exception. |
try {
while (scanner.hasNextLine() && !hasExited()) {
execCommand(scanner.nextLine(), true, isVerbose());
}
} finally {
scanner.close();
} | 1 duplicated blocks of code must be removed. |
if (steps >= 1) {
Map<String,Long> bulkFiles = MetadataTable.getBulkFilesLoaded(SecurityConstants.getSystemCredentials(), extent);
MetadataTable.addNewTablet(low, "/lowDir", instance, lowDatafileSizes, bulkFiles, SecurityConstants.getSystemCredentials(), TabletTime.LOGICAL_TIME_ID
+ "0", -1l, -1l, zl);
} | Either log or rethrow this exception. |
@Test
public void testDeletes() throws IOException {
Text colf = new Text("a");
Text colq = new Text("b");
Value dv = new Value();
TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
Key k = new Key(new Text("0"), colf, colq);
tm.put(k, dv);
k = new Key(new Text("1"), colf, colq, 10);
k.setDeleted(true);
tm.put(k, dv);
k = new Key(new Text("1"), colf, colq, 5);
tm.put(k, dv);
k = new Key(new Text("10"), colf, colq);
tm.put(k, dv);
assertTrue(tm.size() == 4);
Filter filter = new SimpleFilter();
filter.init(new SortedMapIterator(tm), EMPTY_OPTS, null);
filter.seek(new Range(), EMPTY_COL_FAMS, false);
int size = size(filter);
assertTrue("size = " + size, size == 3);
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
setSource(iterator); | Remove the literal "true" boolean value. |
import org.apache.accumulo.core.util.MetadataTable;
import org.apache.accumulo.core.util.RootTable;
MetadataTable.PREV_ROW_COLUMN.put(m, encodePrevEndRow(ke.getPrevEndRow()));
return getTableId().toString().equals(MetadataTable.ID);
return this.compareTo(RootTable.ROOT_TABLET_EXTENT) == 0; | Use "Long.toString" 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. |
package org.apache.accumulo.cloudtrace.instrument;
import org.apache.accumulo.cloudtrace.thrift.TInfo; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
Multimap<String,String> indexedTerms = parseIndexedTerms(options);
Multimap<String,String> normalizedTerms = parseIndexedTerms(options);
private RewriterTreeNode removeNonIndexedTerms(RewriterTreeNode root, Multimap<String,String> indexedTerms) throws Exception {
private RewriterTreeNode orNormalizedTerms(RewriterTreeNode myroot, Multimap<String,String> indexedTerms) throws Exception {
private RewriterTreeNode removeTreeConflicts(RewriterTreeNode root, Multimap<String,String> indexedTerms) { | Define and throw a dedicated exception instead of using a generic one. |
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum { | 300 duplicated blocks of code must be removed. |
List<TabletStats> onlineTabletsForTable = client.getTabletStats(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), tableId); | Immediately return this expression instead of assigning it to the temporary variable "ret". |
String tableName = OptUtil.getTableOpt(cl, shellState);
splits.add(new Text(s.getBytes(Shell.CHARSET)));
base64Opt = new Option("b64", "base64encoded", false, "decode encoded split points (splits file only)"); | Either log or rethrow this exception. |
private Option nameOpt;
String tableName = OptUtil.configureTableOpt(cl, shellState);
o.addOption(OptUtil.tableOpt("table to list the configured iterators on")); | Reduce this switch case number of lines from 8 to at most 5, for example by extracting code into methods. |
/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.accumulo.proxy.thrift;
import java.util.Map;
import java.util.HashMap;
import org.apache.thrift.TEnum;
public enum IteratorScope implements org.apache.thrift.TEnum {
MINC(0),
MAJC(1),
SCAN(2);
private final int value;
private IteratorScope(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
public static IteratorScope findByValue(int value) {
switch (value) {
case 0:
return MINC;
case 1:
return MAJC;
case 2:
return SCAN;
default:
return null;
}
}
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
clazz = AccumuloVFSClassLoader.loadClass(classname, Aggregator.class); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
if (isArchive(fullPath))
return new Path(fullPath);
if (!isArchive(archiving))
throw new IllegalArgumentException(archiving);
if (archiving.contains(name))
return;
if (src.delete(fullPath, true))
log.info(fullPath + " deleted");
else
log.error("Unable to delete " + fullPath); | Remove this call to "exit" or ensure it is really required. |
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
static class Opts {
@Parameter(names="--rows", description="rows", required = true)
int rows = 0;
@Parameter(names="--cols", description="cols")
int cols = 1;
@Parameter(names="--threads", description="threads")
int threads = 1;
@Parameter(names="--writeThreads", description="write threads")
int writeThreads = 1;
@Parameter(names="-help", help=true)
boolean help = false;
}
Opts opts = new Opts();
JCommander jc = new JCommander(opts);
jc.setProgramName(NativeMapConcurrencyTest.class.getName());
jc.parse(args);
if (opts.help) {
jc.usage();
return;
}
NativeMap nm = create(opts.rows, opts.cols);
runTest(nm, opts.rows, opts.cols, opts.threads, opts.writeThreads); | Remove this call to "exit" or ensure it is really required. |
lowDirectory = "/" + Constants.GENERATED_TABLET_DIRECTORY_PREFIX + namer.getNextName(); | Complete the task associated to this TODO comment. |
import org.apache.accumulo.core.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.security.tokens.PasswordToken; | 1 duplicated blocks of code must be removed. |
package org.apache.accumulo.core.security.tokens; | 1 duplicated blocks of code must be removed. |
* Autogenerated by Thrift Compiler (0.9.0)
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
private byte __isset_bitfield = 0;
__isset_bitfield = other.__isset_bitfield;
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PRIORITY_ISSET_ID);
return EncodingUtils.testBit(__isset_bitfield, __PRIORITY_ISSET_ID);
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PRIORITY_ISSET_ID, value);
// check for sub-struct validity
__isset_bitfield = 0; | Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.util.shell.commands.InterpreterCommand;
new InterpreterCommand(), new GrepCommand(), new ImportDirectoryCommand(), new InsertCommand(), new MaxRowCommand(), new ScanCommand()}; | 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.
*/
/** Return the total amount of time elapsed since start was called, if running, or difference between stop and start */
Map<String,String> getData(); | 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");
byte[] data = value.getBytes(utf8);
data = Base64.decodeBase64(value.getBytes(utf8)); | Move this variable to comply with Java Code Conventions. |
if (event.getPath() != null) {
try {
if (ZooReaderWriter.getInstance().exists(event.getPath(), this))
return;
} catch (Exception ex) {
log.error(ex, ex);
}
log.warn("Trace server unable to reset watch on zookeeper registration");
server.stop(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.cli.ClientOnDefaultTable;
import org.apache.accumulo.core.cli.ScannerOpts;
import com.beust.jcommander.Parameter;
static class Opts extends ClientOnDefaultTable {
@Parameter(names={"-l", "--list"}, description="List recent traces")
boolean list = false;
@Parameter(names={"-s", "--start"}, description="The start time of traces to display")
String start;
@Parameter(names={"-e", "--end"}, description="The end time of traces to display")
String end;
@Parameter(names={"-d", "--dump"}, description="Dump the traces")
boolean dump = false;
@Parameter(names={"-i", "--instance"}, description="URL to point to accumulo.")
String instance;
@Parameter(description=" <trace id> { <trace id> ... }")
List<String> traceIds = new ArrayList<String>();
Opts() { super("trace");}
Opts opts = new Opts();
ScannerOpts scanOpts = new ScannerOpts();
opts.parseArgs(TraceDump.class.getName(), args, scanOpts);
if (opts.list) {
code = listSpans(opts, scanOpts);
if (code == 0 && opts.dump) {
code = dumpTrace(opts, scanOpts);
private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception {
Connector conn = opts.getConnector();
Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
private static int dumpTrace(Opts opts, ScannerOpts scanOpts) throws Exception {
Connector conn = opts.getConnector();
for (String traceId : opts.traceIds) {
Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
Range range = new Range(new Text(traceId.toString())); | Remove this unused private "appendProp" method. |
client.loadTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift());
client.unloadTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift(), save);
return client.getTabletServerStatus(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance));
client.halt(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock));
client.fastHalt(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock));
client.flush(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), tableId,
startRow == null ? null : ByteBuffer.wrap(startRow), endRow == null ? null : ByteBuffer.wrap(endRow));
client.chop(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift());
client.splitTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), extent.toThrift(),
client.flushTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift());
client.compact(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), tableId,
private Map<TServerInstance,TServerInfo> currentInstances = new HashMap<TServerInstance,TServerInfo>();
} else if (System.currentTimeMillis() - firstSeen > 10 * 60 * 1000) { | Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable". |
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
| 2 duplicated blocks of code must be removed. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
/**
* 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.file.rfile.bcfile;
import java.util.Collections;
import java.util.Comparator;
import org.apache.hadoop.io.RawComparator;
/**
* Interface for objects that can be compared through {@link RawComparator}.
* This is useful in places where we need a single object reference to specify a
* range of bytes in a byte array, such as {@link Comparable} or
* {@link Collections#binarySearch(java.util.List, Object, Comparator)}
*
* The actual comparison among RawComparable's requires an external
* RawComparator and it is applications' responsibility to ensure two
* RawComparable are supposed to be semantically comparable with the same
* RawComparator.
*/
public interface RawComparable {
/**
* Get the underlying byte array.
*
* @return The underlying byte array.
*/
abstract byte[] buffer();
/**
* Get the offset of the first byte in the byte array.
*
* @return The offset of the first byte in the byte array.
*/
abstract int offset();
/**
* Get the size of the byte range in the byte array.
*
* @return The size of the byte range in the byte array.
*/
abstract int size();
} | Return empty string instead. |
indexMutation.put(new Text(s.description), new Text(s.sender), new Value((idString + ":" + Long.toHexString(diff)).getBytes()));
connector = serverConfiguration.getInstance().getConnector(conf.get(Property.TRACE_USER), conf.get(Property.TRACE_PASSWORD).getBytes());
String path = zoo.putEphemeralSequential(root + "/trace-", name.getBytes());
log.warn("Trace server lost zookeeper registration at " + event.getPath());
log.warn("Trace server zookeeper entry lost " + event.getPath());
try {
if (ZooReaderWriter.getInstance().exists(event.getPath(), this))
return;
} catch (Exception ex) {
log.error(ex, ex);
}
log.warn("Trace server unable to reset watch on zookeeper registration");
server.stop(); | Remove this unused private "appendProp" method. |
@Override
public void unableToMonitorLockNode(Throwable e) {
System.exit(-1);
} | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.cloudtrace.instrument.Tracer;
TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, Monitor.getSystemConfiguration());
tsStats.addAll(client.getTabletStats(Tracer.traceInfo(), SecurityConstants.getSystemCredentials(), tableId));
historical = client.getHistoricalStats(Tracer.traceInfo(), SecurityConstants.getSystemCredentials()); | Immediately return this expression instead of assigning it to the temporary variable "client". |
package org.apache.accumulo.server.test.functional;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.core.zookeeper.ZooCache;
public class CacheTestReader {
public static void main(String[] args) throws Exception {
String rootDir = args[0];
String reportDir = args[1];
String keepers = args[2];
int numData = CacheTestWriter.NUM_DATA;
File myfile = new File(reportDir+"/"+UUID.randomUUID());
myfile.deleteOnExit();
ZooCache zc = new ZooCache(keepers, 30000);
while(true){
if(myfile.exists())
myfile.delete();
if(zc.get(rootDir+"/die") != null){
return;
}
Map<String, String> readData = new TreeMap<String, String>();
for(int i = 0; i < numData; i++){
byte[] v = zc.get(rootDir+"/data"+i);
if(v != null)
readData.put(rootDir+"/data"+i, new String(v));
}
byte[] v = zc.get(rootDir+"/dataS");
if(v != null)
readData.put(rootDir+"/dataS", new String(v));
List<String> children = zc.getChildren(rootDir+"/dir");
if(children != null)
for (String child : children) {
readData.put(rootDir+"/dir/"+child, "");
}
FileOutputStream fos = new FileOutputStream(myfile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(readData);
oos.close();
UtilWaitThread.sleep(20);
}
}
} | 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. |
/*
* 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]*$'. |
@Override
public Long typedReduce(Key key, Iterator<Long> iter) {
long max = Long.MIN_VALUE;
while (iter.hasNext()) {
Long l = iter.next();
if (l > max) max = l;
return max;
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
}, 1000, 10 * 60 * 1000); | Refactor this code to not nest more than 3 if/for/while/switch/try statements. |
package org.apache.accumulo.test.randomwalk.concurrent;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import java.util.Random;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
public class ListSplits 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 {
Collection<Text> splits = conn.tableOperations().listSplits(tableName);
log.debug("Table " + tableName + " had " + splits.size() + " splits");
} catch (TableNotFoundException e) {
log.debug("listSplits " + tableName + " failed, doesnt exist");
} catch (AccumuloSecurityException ase) {
log.debug("listSplits " + tableName + " failed, " + ase.getMessage());
}
}
} | Either log or rethrow this exception. |
public void setPrevKey(Key pk) {
this.prevKey = pk;
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
package org.apache.accumulo.server.mini;
import org.apache.accumulo.server.mini.MiniAccumuloCluster;
// folder.delete(); | This block of commented-out lines of code should be removed. |
import org.apache.accumulo.core.cli.ClientOnRequiredTable;
ClientOnRequiredTable opts = new ClientOnRequiredTable();
opts.parseArgs(Flush.class.getName(), args);
Connector connector = opts.getConnector();
connector.tableOperations().flush(opts.tableName, null, null, true); | Remove this call to "exit" or ensure it is really required. |
return protocolFactories.get(random.nextInt(protocolFactories.size()));
proxyPort = MiniAccumuloCluster.getRandomFreePort(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
new File(System.getProperty("java.io.tmpdir"), "accumulo-vfs-cache-" + System.getProperty("user.name", "nouser")) | Replace all tab characters in this file by sequences of white-spaces. |
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]*$'. |
Constants.METADATA_TIME_COLUMN.put(mut, new Value("M0".getBytes()));
Constants.METADATA_DIRECTORY_COLUMN.put(mut, new Value("/default_tablet".getBytes()));
Constants.METADATA_TIME_COLUMN.put(mut, new Value("M0".getBytes()));
Constants.METADATA_DIRECTORY_COLUMN.put(mut, new Value("/default_tablet".getBytes()));
Constants.METADATA_PREV_ROW_COLUMN.putDelete(mut);
Constants.METADATA_TIME_COLUMN.putDelete(mut);
Constants.METADATA_DIRECTORY_COLUMN.putDelete(mut);
Constants.METADATA_TIME_COLUMN.put(mut, new Value("M0".getBytes()));
Constants.METADATA_DIRECTORY_COLUMN.put(mut, new Value(dir.getBytes())); | Replace all tab characters in this file by sequences of white-spaces. |
* don't want iterators affecting the performance of tablet servers.<br>
* <br>
* Suggested usage:<br>
* <code>Scanner scanner = new ClientSideIteratorScanner(connector.createScanner(tableName, authorizations));</code><br>
* <br>
* Iterators added to this scanner will be run in the client JVM. Separate scan iterators can be run on the server side and client side by adding iterators to
* the source scanner (which will execute server side) and to the client side scanner (which will execute client side).
/**
* A class that wraps a Scanner in a SortedKeyValueIterator so that other accumulo iterators can use it as a source.
*/
/**
* Constructs an accumulo iterator from a scanner.
*
* @param scanner
* the scanner to iterate over
*/
private ScannerTranslator smi;
/**
* Constructs a scanner that can execute client-side iterators.
*
* @param scanner
* the source scanner
*/
/**
* Sets the source Scanner.
*
* @param scanner
*/ | Complete the task associated to this TODO comment. |
AccumuloInputFormat.setZooKeeperInstance(job.getConfiguration(), args[0], args[1]);
AccumuloInputFormat.setInputInfo(job.getConfiguration(), args[2], args[3].getBytes(), args[4], new Authorizations());
AccumuloInputFormat.fetchColumns(job.getConfiguration(), columnsToFetch); | Remove this unused private "debugQuery" method. |
import org.apache.accumulo.core.Constants;
@Parameter(names = "--root", description = "the root of the znode tree to dump")
return new Encoded("base64", new String(Base64.encodeBase64(data), Constants.UTF8));
return new Encoded(Constants.UTF8.name(), new String(data, Constants.UTF8)); | Move this variable to comply with Java Code Conventions. |
port = TServerUtils.startTServer(result, processor, this.getClass().getSimpleName(), "GC Monitor Service", 2, 1000, maxMessageSize).address.getPort(); | Either log or rethrow this exception. |
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(); | Define a constant instead of duplicating this literal " for table " 4 times. |
public static String encodeAsBase64FileName(Text data) {
String encodedRow = new String(Base64.encodeBase64(TextUtil.getBytes(data)));
encodedRow = encodedRow.replace('/', '_').replace('+', '-');
int index = encodedRow.length() - 1;
while (index >= 0 && encodedRow.charAt(index) == '=')
index--;
encodedRow = encodedRow.substring(0, index + 1);
return encodedRow;
}
public static byte[] decodeBase64FileName(String node) {
while (node.length() % 4 != 0)
node += "=";
node = node.replace('_', '/').replace('-', '+');
return Base64.decodeBase64(node.getBytes());
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
import org.apache.accumulo.core.util.ComparablePair;
@SuppressWarnings("unchecked")
assertSortOrder(plexc, new ComparablePair<String,String>("a", "b"), new ComparablePair<String,String>("a", "bc"), new ComparablePair<String,String>("a",
"c"), new ComparablePair<String,String>("ab", "c"), new ComparablePair<String,String>("ab", ""), new ComparablePair<String,String>("ab", "d"),
new ComparablePair<String,String>("b", "f"), new ComparablePair<String,String>("b", "a"));
assertSortOrder(plexc2, new ComparablePair<Long,String>(0x100l, "a"), new ComparablePair<Long,String>(0x100l, "ab"), new ComparablePair<Long,String>(0xf0l,
"a"), new ComparablePair<Long,String>(0xf0l, "ab")); | Override "equals(Object obj)" to comply with the contract of the "compareTo(T o)" method. |
import org.apache.accumulo.core.security.tokens.UserPassToken;
Connector conn = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZookeepers()).getConnector(new UserPassToken("root", "superSecret"));
UserPassToken upt = new UserPassToken("user1", "pass1");
conn.securityOperations().createUser(upt);
Connector uconn = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZookeepers()).getConnector(upt);
Connector conn = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZookeepers()).getConnector(new UserPassToken("root", "superSecret"));
// folder.delete(); | Immediately return this expression instead of assigning it to the temporary variable "ret". |
internal.add(new AuthProperty("password", "the password for the principal", true)); | Rename "principal" which hides the field declared at line 173. |
private Option forceOpt;
String tableName = OptUtil.getTableOpt(cl, shellState);
Text startRow = OptUtil.getStartRow(cl);
Text endRow = OptUtil.getEndRow(cl);
o.addOption(OptUtil.startRowOpt());
o.addOption(OptUtil.endRowOpt()); | Either log or rethrow this exception. |
import java.util.List;
import org.apache.accumulo.core.cli.Help;
import com.beust.jcommander.Parameter;
static class Opts extends Help {
@Parameter(names="-m", description="the maximum size of the key/value pair to shunt to the small file")
long maxSize = 10 * 1024 * 1024;
@Parameter(description="<file.rf> { <file.rf> ... }")
List<String> files = new ArrayList<String>();
}
Opts opts = new Opts();
opts.parseArgs(SplitLarge.class.getName(), args);
for (String file : opts.files) {
Path path = new Path(file);
if (!file.endsWith(".rf")) {
String smallName = file.substring(0, file.length() - 3) + "_small.rf";
String largeName = file.substring(0, file.length() - 3) + "_large.rf"; | Remove this unused private "appendProp" method. |
if (!evictionLock.tryLock())
return;
if (bytesToFree <= 0)
return;
if (this.overflow() == that.overflow())
return 0;
if (cache == null)
break; | 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.test.functional;
import org.apache.accumulo.minicluster.MiniAccumuloCluster;
import org.apache.accumulo.minicluster.MiniAccumuloConfig;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.rules.TemporaryFolder;
public class ConfigurableMacIT extends AbstractMacIT {
public static final Logger log = Logger.getLogger(ConfigurableMacIT.class);
public TemporaryFolder folder = new TemporaryFolder();
public MiniAccumuloCluster cluster;
@Before
public void setUp() throws Exception {
folder.create();
MiniAccumuloConfig cfg = new MiniAccumuloConfig(folder.newFolder(this.getClass().getSimpleName()), ROOT_PASSWORD);
configure(cfg);
cluster = new MiniAccumuloCluster(cfg);
cluster.start();
}
public void configure(MiniAccumuloConfig cfg) {
}
@After
public void tearDown() throws Exception {
cleanUp(cluster, folder);
}
@Override
public MiniAccumuloCluster getCluster() {
return cluster;
}
} | Either log or rethrow this exception. |
package org.apache.accumulo.server.test.randomwalk.multitable;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Random;
import java.util.UUID;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.server.test.randomwalk.State;
import org.apache.accumulo.server.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
public class Write extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
if (tables.isEmpty()) {
log.debug("No tables to ingest into");
return;
}
Random rand = new Random();
String tableName = tables.get(rand.nextInt(tables.size()));
BatchWriter bw = null;
try {
bw = state.getMultiTableBatchWriter().getBatchWriter(tableName);
} catch (TableNotFoundException e) {
log.error("Table "+tableName+" not found!");
return;
}
Text meta = new Text("meta");
String uuid = UUID.randomUUID().toString();
Mutation m = new Mutation(new Text(uuid));
// create a fake payload between 4KB and 16KB
int numBytes = rand.nextInt(12000) + 4000;
byte[] payloadBytes = new byte[numBytes];
rand.nextBytes(payloadBytes);
m.put(meta, new Text("payload"), new Value(payloadBytes));
// store size
m.put(meta, new Text("size"), new Value(String.format("%d", numBytes).getBytes()));
// store hash
MessageDigest alg = MessageDigest.getInstance("SHA-1");
alg.update(payloadBytes);
m.put(meta, new Text("sha1"), new Value(alg.digest()));
// add mutation
bw.addMutation(m);
state.set("numWrites", state.getInteger("numWrites")+1);
}
} | Return empty string instead. |
import java.io.IOException;
import org.apache.hadoop.mapreduce.Job;
public void testNoSubBins() throws IOException {
public void testSubBins() throws IOException {
private RangePartitioner prepPartitioner(int numSubBins) throws IOException {
Job job = new Job();
private void checkExpectedRangeBins(int numSubBins, String[] strings, int[] rangeEnds) throws IOException {
private void checkExpectedBins(int numSubBins, String[] strings, int[] bins) throws IOException { | 2 duplicated blocks of code must be removed. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.