Diff
stringlengths 10
2k
| Message
stringlengths 28
159
|
---|---|
import java.io.FileNotFoundException;
delete(child.getPath());
private boolean delete(Path p) throws IOException {
try {
return trash.moveToTrash(p) || fs.delete(p, true);
} catch (FileNotFoundException ex) {
return false;
}
}
if (now - child.getModificationTime() > maxAgeInMillis && !delete(child.getPath())) { | 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. |
if (readValue)
top_value = new Value();
if (readValue)
valid = reader.next(top_key, top_value);
else
valid = reader.next(top_key); | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.core.util.format.DefaultFormatter;
import org.apache.accumulo.core.util.interpret.DefaultScanInterpreter;
TABLE_FORMATTER_CLASS("table.formatter", DefaultFormatter.class.getName(), PropertyType.STRING,
"The Formatter class to apply on results in the shell"),
TABLE_INTERPRETER_CLASS("table.interepreter", DefaultScanInterpreter.class.getName(), PropertyType.STRING,
"The ScanInterpreter class to apply on scan arguments in the shell"); | Return empty string instead. |
log.debug("completing bulk import transaction " + tid);
ZooArbitrator.cleanup(Constants.BULK_ARBITRATOR_TYPE, tid); | Either log or rethrow this exception. |
import java.io.UnsupportedEncodingException;
private Option scanOptAuths, scanOptRow, scanOptColumns, disablePaginationOpt, showFewOpt, formatterOpt;
String tableName = OptUtil.getTableOpt(cl, shellState);
protected void fetchColumns(CommandLine cl, ScannerBase scanner) throws UnsupportedEncodingException {
scanner.fetchColumnFamily(new Text(a.getBytes(Shell.CHARSET)));
scanner.fetchColumn(new Text(sa[0].getBytes(Shell.CHARSET)), new Text(sa[1].getBytes(Shell.CHARSET)));
protected Range getRange(CommandLine cl) throws UnsupportedEncodingException {
if ((cl.hasOption(OptUtil.START_ROW_OPT) || cl.hasOption(OptUtil.END_ROW_OPT)) && cl.hasOption(scanOptRow.getOpt())) {
throw new IllegalArgumentException("Options -" + scanOptRow.getOpt() + " AND (-" + OptUtil.START_ROW_OPT + " OR -" + OptUtil.END_ROW_OPT
return new Range(new Text(cl.getOptionValue(scanOptRow.getOpt()).getBytes(Shell.CHARSET)));
Text startRow = OptUtil.getStartRow(cl);
Text endRow = OptUtil.getEndRow(cl);
o.addOption(OptUtil.startRowOpt());
o.addOption(OptUtil.endRowOpt()); | Either log or rethrow this exception. |
if (rand.nextBoolean())
changeSystemPermission(conn, rand, userName);
else
changeTablePermission(conn, rand, userName, tableName);
if (conn.securityOperations().hasTablePermission(userName, tableName, p))
perms.add(p);
if (conn.securityOperations().hasSystemPermission(userName, p))
perms.add(p); | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.PartialKey;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.IteratorEnvironment;
import org.apache.accumulo.core.iterators.OptionDescriber;
import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
throw new IllegalArgumentException("Failed to parse query", ex);
throw new IllegalArgumentException("probably had no indexed terms", ex); | Complete the task associated to this TODO comment. |
@Deprecated | Remove this unused method parameter "ex". |
* 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.
*/
log.debug("Creating user " + userName); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.server.zookeeper.IZooReaderWriter;
IZooReaderWriter zoo = ZooReaderWriter.getInstance(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
* A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in
* must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are
* passed, then an exception will be thrown.
* A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in
* must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are
* passed, then an exception will be thrown.
* A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in
* must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are
* passed, then an exception will be thrown. | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.server.cli.ClientOpts;
Text row = new Text(String.format("%s%s%020d%s", MetadataTable.DELETED_RANGE.getStartKey().getRow().toString(), "/", i, | Reduce this switch case number of lines from 12 to at most 5, for example by extracting code into methods. |
import org.apache.accumulo.core.client.security.SecurityErrorCode; | Do not forget to remove this deprecated code someday. |
if (!shellState.getConnector().tableOperations().testClassLoad(tableName, constraint, Constraint.class.getName())) { | Either log or rethrow this exception. |
package org.apache.accumulo.core.util; | 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(FileDataIngest.class.getName(), args, bwOpts);
BatchWriter bw = conn.createBatchWriter(opts.tableName, bwOpts.getBatchWriterConfig()); | Remove this unused method parameter "opts". |
import org.apache.accumulo.server.security.SecurityUtil;
SecurityUtil.serverLogin();
| Move this variable to comply with Java Code Conventions. |
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public void init(Map<String,String> options);
public boolean accept(Key k, Value v); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
public class BloomFilterIT extends ConfigurableMacIT { | Use "Integer.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.
*/
package org.apache.accumulo.core.security.tokens;
import javax.security.auth.Destroyable;
import org.apache.hadoop.io.Writable;
public interface SecurityToken extends Writable, Destroyable, Cloneable {
public SecurityToken clone();
} | Replace this if-then-else statement by a single return statement. |
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
org.apache.thrift.protocol.TList _list31 = iprot.readListBegin();
this.mutations = new ArrayList<org.apache.accumulo.core.data.thrift.TMutation>(_list31.size);
for (int _i32 = 0; _i32 < _list31.size; ++_i32)
org.apache.accumulo.core.data.thrift.TMutation _elem33;
_elem33 = new org.apache.accumulo.core.data.thrift.TMutation();
_elem33.read(iprot);
this.mutations.add(_elem33);
for (org.apache.accumulo.core.data.thrift.TMutation _iter34 : this.mutations)
_iter34.write(oprot); | Use "Long.toString" instead. |
import org.apache.accumulo.core.cli.BatchWriterOpts;
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(SequentialBatchWriter.class.getName(), args, bwOpts);
BatchWriter bw = connector.createBatchWriter(opts.tableName, bwOpts.getBatchWriterConfig()); | Remove this unused method parameter "opts". |
import org.apache.accumulo.core.security.thrift.TCredentials;
private TCredentials credentials;
public ConnectorImpl(Instance instance, TCredentials cred) throws AccumuloException, AccumuloSecurityException {
if (!iface.authenticate(Tracer.traceInfo(), credentials)) | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.accumulo.start.classloader.vfs.providers;
/**
* HDFS file content attributes.
*
* @since 2.1
*/
public enum HdfsFileAttributes
{
/**
* Last access time.
*/
LAST_ACCESS_TIME,
/**
* Block size.
*/
BLOCK_SIZE,
/**
* Group.
*/
GROUP,
/**
* Owner.
*/
OWNER,
/**
* Permissions.
*/
PERMISSIONS,
/**
* Length.
*/
LENGTH,
/**
* Modification time.
*/
MODIFICATION_TIME;
} | Remove this unused private "appendProp" method. |
shellState.getReader().println(StringUtils.join(set, ',')); | 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. |
PasswordToken newPass = new PasswordToken(newPassw);
conn.securityOperations().changeLocalUserPassword(target, newPass); | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
for (String key : IteratorUtil.generateInitialTableProperties().keySet()) | Remove this unused private "match" method. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
package org.apache.accumulo.test.randomwalk.multitable;
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. |
private final ZooCache zooCache;
private final String zooKeepers;
private final int zooKeepersSessionTimeOut;
@Deprecated
/**
* To be moved to server code. Only lives here to support certain client side utilities to minimize command-line options.
*/ | Extract the assignment out of this expression. |
import java.util.Set; | 2 duplicated blocks of code must be removed. |
private Runnable runnable;
private Logger log;
public LoggingRunnable(Logger log, Runnable r) {
this.runnable = r;
this.log = log;
}
public void run() {
try {
runnable.run();
} catch (Throwable t) {
try {
log.error("Thread \"" + Thread.currentThread().getName() + "\" died " + t.getMessage(), t);
} catch (Throwable t2) {
// maybe the logging system is screwed up OR there is a bug in the exception, like t.getMessage() throws a NPE
System.err.println("ERROR " + new Date() + " Failed to log message about thread death " + t2.getMessage());
t2.printStackTrace();
// try to print original exception
System.err.println("ERROR " + new Date() + " Exception that failed to log : " + t.getMessage());
t.printStackTrace();
}
}
public static void main(String[] args) {
Runnable r = new Runnable() {
@Override
public void run() {
int x[] = new int[0];
x[0]++;
}
};
LoggingRunnable lr = new LoggingRunnable(null, r);
lr.run();
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
final SortedMap<Long,byte[]> locks = new TreeMap<Long,byte[]>();
final Lock readLock = locker.readLock();
final Lock writeLock = locker.writeLock();
final Lock wl = locker.writeLock();
final Lock rl = locker.readLock(); | Move this variable to comply with Java Code Conventions. |
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.TableNotFoundException;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.server.test.randomwalk.State;
import org.apache.accumulo.server.test.randomwalk.Test;
public class OfflineTable 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().offline(tableName);
log.debug("Offlined "+tableName);
UtilWaitThread.sleep(rand.nextInt(200));
conn.tableOperations().online(tableName);
log.debug("Onlined "+tableName);
}catch(TableNotFoundException tne){
log.debug("offline or online failed "+tableName+", doesnt exist");
}
}
} | Return empty string instead. |
import java.nio.charset.Charset;
AccumuloInputFormat.setConnectorInfo(job, args[0], args[1].getBytes(Charset.forName("UTF-8")));
AccumuloInputFormat.setInputTableName(job, args[2]);
AccumuloOutputFormat.setConnectorInfo(job, args[0], args[1].getBytes(Charset.forName("UTF-8")));
AccumuloOutputFormat.setCreateTables(job, true);
AccumuloOutputFormat.setDefaultTableName(job, args[5]); | Either log or rethrow this exception. |
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; | 1 duplicated blocks of code must be removed. |
import org.apache.accumulo.core.security.thrift.Credentials;
private Credentials credentials;
ScannerIterator(Instance instance, Credentials credentials, Text table, Authorizations authorizations, Range range, int size, int timeOut, | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
public void initialize(String instanceId, boolean initialize); | Remove this call to "exit" or ensure it is really required. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
private Counters c = new Counters();
private long filesProcessed = 0;
private long recordsProcessed = 0;
public Counters getCounters() {
return c;
}
@Override
public Counter getCounter(Enum<?> name) {
return c.findCounter(name);
}
@Override
public Counter getCounter(String group, String name) {
return c.findCounter(group, name);
}
@Override
public void progress() {
// do nothing
}
@Override
public void setStatus(String status) {
// do nothing
}
public long getFilesProcessed() {
return filesProcessed;
}
public long getRecordsProcessed() {
return recordsProcessed;
}
public void incrementFilesProcessed() {
filesProcessed++;
recordsProcessed = 0;
}
public void incrementRecordsProcessed() {
recordsProcessed++;
} | Immediately return this expression instead of assigning it to the temporary variable "r". |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.core.util.ContextFactory;
JobContext job = ContextFactory.createJobContext(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/**
* @deprecated since 1.4
* @use org.apache.accumulo.core.iterators.user.MinCombiner with MinCombiner.Type.STRING
*/ | 1 duplicated blocks of code must be removed. |
import java.text.ParseException;
try {
initDateParser().parse(start);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
try {
initDateParser().parse(end);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
setStart(is, initDateParser().format(new Date(start)), startInclusive);
setEnd(is, initDateParser().format(new Date(end)), endInclusive); | Either log or rethrow this exception. |
exec("classpath", true, "Level 2: Accumulo Start Classloader (Loads the classloader) URL classpath items are", true); | 1 duplicated blocks of code must be removed. |
package org.apache.accumulo.test.continuous;
import org.apache.accumulo.test.continuous.ContinuousIngest.BaseOpts; | Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison. |
import org.apache.accumulo.core.security.Authorizations;
Scanner scanner = getConnector().createScanner("rdel1", Authorizations.EMPTY);
scanner = getConnector().createScanner("rdel1", Authorizations.EMPTY);
scanner = getConnector().createScanner("rdel1", Authorizations.EMPTY); | Remove this unused method parameter "range". |
Collection<Text> splits = getConnector().tableOperations().listSplits(table); | Either log or rethrow this exception. |
import java.nio.charset.Charset;
private static final Charset utf8 = Charset.forName("UTF8");
byte[] nid = zoo.mutate(ntp, "0".getBytes(utf8), ZooUtil.PUBLIC, new Mutator() {
return nextId.toString(Character.MAX_RADIX).getBytes(utf8);
String resvPath = ZooUtil.getRoot(instance) + Constants.ZHDFS_RESERVATIONS + "/" + new String(Base64.encodeBase64(directory.getBytes(utf8)));
String resvPath = ZooUtil.getRoot(instance) + Constants.ZHDFS_RESERVATIONS + "/" + new String(Base64.encodeBase64(directory.getBytes(utf8)));
byte[] lockData = String.format("%016x", tid).getBytes(utf8); | Move this variable to comply with Java Code Conventions. |
private static final long serialVersionUID = 1L;
private String tableId;
public TableDeletedException(String tableId) {
this.tableId = tableId;
}
public String getTableId() {
return tableId;
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
private static String authsFile = null;
} else if (args[i].equals("--auths")) {
authsFile = args[++i];
static class RandomAuths {
private List<Authorizations> auths;
RandomAuths(String file) throws IOException {
if (file == null) {
auths = Collections.singletonList(Constants.NO_AUTHS);
return;
}
auths = new ArrayList<Authorizations>();
FileSystem fs = FileSystem.get(new Configuration());
BufferedReader in = new BufferedReader(new InputStreamReader(fs.open(new Path(file))));
String line;
while ((line = in.readLine()) != null) {
auths.add(new Authorizations(line.split(",")));
}
in.close();
}
Authorizations getAuths(Random r) {
return auths.get(r.nextInt(auths.size()));
}
}
+ " [--debug <debug log>] [--auths <file>] <instance name> <zookeepers> <user> <pass> <table> <min> <max> <sleep time>");
RandomAuths randomAuths = new RandomAuths(authsFile);
Scanner scanner = conn.createScanner(table, randomAuths.getAuths(r));
cksum.update(key.getColumnVisibilityData().toArray()); | Remove this unused method parameter "r". |
public void init(Map<String,String> options);
public boolean accept(Key k, Value v); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
boolean tabExists = SecurityHelper.getTableExists(state);
target = SecurityHelper.getTabUserName(state);
target = SecurityHelper.getSysUserName(state);
boolean exists = SecurityHelper.getTabUserExists(state);
boolean tableExists = SecurityHelper.getTableExists(state);
boolean hasPerm = SecurityHelper.getTabPerm(state, target, tabPerm);
conn = SecurityHelper.getSystemConnector(state);
canGive = SecurityHelper.getSysPerm(state, SecurityHelper.getSysUserName(state), SystemPermission.ALTER_USER)
|| SecurityHelper.getTabPerm(state, SecurityHelper.getSysUserName(state), TablePermission.GRANT);
conn = state.getInstance().getConnector(SecurityHelper.getTabUserName(state), SecurityHelper.getTabUserPass(state));
canGive = SecurityHelper.getTabPerm(state, SecurityHelper.getTabUserName(state), TablePermission.GRANT);
canGive = true;
if (hasPerm != (res = state.getConnector().securityOperations().hasTablePermission(target, SecurityHelper.getTableName(state), tabPerm)))
conn.securityOperations().revokeTablePermission(target, SecurityHelper.getTableName(state), tabPerm);
throw new AccumuloException("Test user failed to give permission when it should have worked", ae);
if (!SecurityHelper.sysUserPassTransient(state))
SecurityHelper.setTabPerm(state, target, tabPerm, false);
conn.securityOperations().grantTablePermission(target, SecurityHelper.getTableName(state), tabPerm);
throw new AccumuloException("Test user failed to give permission when it should have worked", ae);
if (!SecurityHelper.sysUserPassTransient(state))
SecurityHelper.setTabPerm(state, target, tabPerm, true);
throw new AccumuloException("Source user shouldn't have been able to grant privilege"); | Either log or rethrow this exception. |
System.out.printf("Mutation add rate : %,6.2f mutations/sec%n", mutationsAdded / ((System.currentTimeMillis() - startTime) / 1000.0)); | Use isEmpty() to check whether the collection is empty or not. |
private final MockAccumulo acc;
private final String tableName;
private final Authorizations authorizations;
/**
* Create a {@link BatchDeleter} for the specified instance on the specified table where the writer uses the specified {@link Authorizations}.
*
* @param acc
* @param tableName
* @param auths
*/
public MockBatchDeleter(MockAccumulo acc, String tableName, Authorizations auths) {
super(acc.tables.get(tableName), auths);
this.authorizations = auths;
this.acc = acc;
this.tableName = tableName;
}
@Override
public void delete() throws MutationsRejectedException, TableNotFoundException {
BatchWriter writer = new MockBatchWriter(acc, tableName);
try {
// super.setScanIterators(Integer.MAX_VALUE,
// SortedKeyIterator.class.getName(), BatchDeleter.class.getName()
// + ".NOVALUE");
Iterator<Entry<Key,Value>> iter = super.iterator();
while (iter.hasNext()) {
Entry<Key,Value> next = iter.next();
Key k = next.getKey();
Mutation m = new Mutation(k.getRow());
m.putDelete(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp());
writer.addMutation(m);
}
} finally {
writer.close();
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.security.tokens.AccumuloToken;
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper;
@SuppressWarnings("deprecation")
* @deprecated @since 1.5, use {@link #getConnector(AccumuloToken)}
* @param token
* An AccumuloToken implementing object.
* @return the accumulo Connector
* @throws AccumuloException
* when a generic exception occurs
* @throws AccumuloSecurityException
* when a user's credentials are invalid
*/
public abstract Connector getConnector(AccumuloToken<?,?> token) throws AccumuloException, AccumuloSecurityException;
/**
* Returns a connection to accumulo.
*
* @param token
* An InstanceTokenWrapper.
* @return the accumulo Connector
* @throws AccumuloException
* when a generic exception occurs
* @throws AccumuloSecurityException
* when a user's credentials are invalid
*/
public abstract Connector getConnector(InstanceTokenWrapper token) throws AccumuloException, AccumuloSecurityException;
/**
* Returns a connection to accumulo.
*
* @deprecated @since 1.5, use {@link #getConnector(AccumuloToken)}
* @deprecated @since 1.5, use {@link #getConnector(AccumuloToken)} | Immediately return this expression instead of assigning it to the temporary variable "ret". |
package org.apache.accumulo.server.master.state;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
public enum TabletServerState
{
// not a valid state, reserved for internal use only
RESERVED((byte)(-1)),
// the following are normally functioning states
NEW((byte)0),
ONLINE((byte)1),
UNRESPONSIVE((byte)2),
DOWN((byte)3),
// the following are bad states and cause tservers to be ignored by the master
BAD_SYSTEM_PASSWORD((byte)101),
BAD_VERSION((byte)102),
BAD_INSTANCE((byte)103),
BAD_CONFIG((byte)104),
BAD_VERSION_AND_INSTANCE((byte)105),
BAD_VERSION_AND_CONFIG((byte)106),
BAD_VERSION_AND_INSTANCE_AND_CONFIG((byte)107),
BAD_INSTANCE_AND_CONFIG((byte)108);
private byte id;
private static HashMap<Byte, TabletServerState> mapping;
private static HashSet<TabletServerState> badStates;
static
{
mapping = new HashMap<Byte, TabletServerState>(TabletServerState.values().length);
badStates = new HashSet<TabletServerState>();
for (TabletServerState state : TabletServerState.values())
{
mapping.put(state.id, state);
if (state.id > 99)
badStates.add(state);
}
}
private TabletServerState(byte id)
{ this.id = id; }
public byte getId()
{ return this.id; }
public static TabletServerState getStateById(byte id)
{
if (mapping.containsKey(id))
return mapping.get(id);
throw new IndexOutOfBoundsException("No such state");
}
public static Set<TabletServerState> getBadStates()
{
return Collections.unmodifiableSet(badStates);
}
} | 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.
*/ | 296 duplicated blocks of code must be removed. |
import org.apache.accumulo.server.cli.ClientOpts;
import org.apache.accumulo.core.cli.BatchWriterOpts;
import org.apache.accumulo.core.cli.ScannerOpts;
private static TreeSet<RowColumn> scanAll(ClientOpts opts, ScannerOpts scanOpts, Text t) throws Exception {
Connector conn = opts.getConnector();
scanner.setBatchSize(scanOpts.scanBatchSize);
private static long scrambleDeleteHalfAndCheck(ClientOpts opts, ScannerOpts scanOpts, BatchWriterOpts bwOpts, Text t, Set<RowColumn> rows) throws Exception {
Connector connector = opts.getConnector();
BatchWriter mutations = connector.createBatchWriter(t.toString(), bwOpts.getBatchWriterConfig());
m.putDelete(new Text(rc.column.columnFamily), new Text(rc.column.columnQualifier), new ColumnVisibility(rc.column.getColumnVisibility()), rc.timestamp + 1);
Set<RowColumn> current = scanAll(opts, scanOpts, t);
ClientOpts opts = new ClientOpts();
ScannerOpts scanOpts = new ScannerOpts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(TestRandomDeletes.class.getName(), args, scanOpts, bwOpts);
TreeSet<RowColumn> doomed = scanAll(opts, scanOpts, t);
long half = scrambleDeleteHalfAndCheck(opts, scanOpts, bwOpts, t, doomed); | Remove this unused private "appendProp" method. |
import java.util.Collections;
import java.util.Map.Entry;
import org.junit.Rule;
public static File testDir;
File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests");
baseDir.mkdirs();
testDir = new File(baseDir, MiniAccumuloClusterTest.class.getName());
FileUtils.deleteQuietly(testDir);
testDir.mkdir();
MiniAccumuloConfig config = new MiniAccumuloConfig(testDir, "superSecret").setJDWPEnabled(true);
@Rule
public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
File jarFile = folder.newFile("iterator.jar");
| 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. |
CompactionPlan plan = getCompactionPlan(request);
return plan != null && !plan.inputFiles.isEmpty(); | This block of commented-out lines of code should be removed. |
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
clazz = AccumuloVFSClassLoader.loadClass(className, OptionDescriber.class); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.cli.Help;
import com.beust.jcommander.Parameter;
public class RestoreZookeeper {
byte[] data = value.getBytes();
data = Base64.decodeBase64(value.getBytes());
static class Opts extends Help {
@Parameter(names={"-z", "--keepers"})
String keepers = "localhost:2181";
@Parameter(names="--overwrite")
boolean overwrite = false;
@Parameter(names="--file")
String file;
}
Opts opts = new Opts();
opts.parseArgs(RestoreZookeeper.class.getName(), args);
if (opts.file != null) {
in = new FileInputStream(opts.file);
ZooKeeper zk = new ZooKeeper(opts.keepers, timeout, new Watcher() {
parser.parse(in, new Restore(zk, opts.overwrite)); | Remove this unused private "appendProp" method. |
if (b.length < offset + 8)
throw new IOException("trying to convert to long, but byte array isn't long enough, wanted " + (offset + 8) + " found " + b.length); | Remove this call to "exit" or ensure it is really required. |
super.seek(range, columnFamilies, inclusive); | At most one statement is allowed per line, but 2 statements were found on this line. |
import org.apache.accumulo.fate.Repo;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; | Remove this call to "exit" or ensure it is really required. |
@SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum { | 300 duplicated blocks of code must be removed. |
import org.apache.accumulo.core.iterators.user.GrepIterator; | Remove this unused private "match" method. |
@Test(timeout = 2 * 60 * 1000) | Either log or rethrow this exception. |
shellState.getReader().printString(String.format("%-15s => %10s%n", tableName, tableIds.get(tableName))); | Use isEmpty() to check whether the collection is empty or not. |
import org.apache.accumulo.core.util.AddressUtil;
transport = ThriftUtil.createTransport(AddressUtil.parseAddress(tserver), instance.getConfiguration()); | Immediately return this expression instead of assigning it to the temporary variable "client". |
Constants.METADATA_DIRECTORY_COLUMN.put(m, new Value(FastFormat.toZeroPaddedString(dirCount++, 8, 16, "/c-".getBytes())));
Constants.METADATA_DIRECTORY_COLUMN.put(m, new Value(FastFormat.toZeroPaddedString(dirCount++, 8, 16, "/c-".getBytes()))); | Remove this unused method parameter "ex". |
/**
*
*/
package org.apache.accumulo.core.util;
import java.io.Serializable;
import java.util.Comparator;
public class ByteArrayComparator implements Comparator<byte[]>, Serializable
{
private static final long serialVersionUID = 1L;
@Override
public int compare(byte[] o1, byte[] o2) {
int minLen = Math.min(o1.length, o2.length);
for(int i = 0; i < minLen; i++){
int a = (o1[i] & 0xff);
int b = (o2[i] & 0xff);
if (a != b) {
return a - b;
}
}
return o1.length - o2.length;
}
} | Return empty string instead. |
@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()));
// TODO need to sometimes do null start and end ranges
TreeSet<Text> range = new TreeSet<Text>();
range.add(new Text(String.format("%016x", Math.abs(rand.nextLong()))));
range.add(new Text(String.format("%016x", Math.abs(rand.nextLong()))));
try {
boolean wait = rand.nextBoolean();
conn.tableOperations().compact(tableName, range.first(), range.last(), false, wait);
log.debug((wait ? "compacted " : "initiated compaction ") + tableName);
} catch (TableNotFoundException tne) {
log.debug("compact " + tableName + " failed, doesnt exist");
} catch (TableOfflineException toe) {
log.debug("compact " + tableName + " failed, offline");
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.server.security.SecurityOperationImpl;
SecurityOperationImpl.getInstance().grantTablePermission(SecurityConstants.getSystemCredentials(), cloneInfo.user, cloneInfo.tableId, permission);
SecurityOperationImpl.getInstance().deleteTable(SecurityConstants.getSystemCredentials(), cloneInfo.tableId); | 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. |
TimestampFilter copy = (TimestampFilter) super.deepCopy(env);
copy.hasStart = hasStart;
copy.start = start;
copy.startInclusive = startInclusive;
copy.hasEnd = hasEnd;
copy.end = end;
copy.endInclusive = endInclusive;
return copy; | Define and throw a dedicated exception instead of using a generic one. |
@Deprecated | Return empty string instead. |
import org.apache.accumulo.cloudtrace.instrument.Span;
import org.apache.accumulo.cloudtrace.instrument.Trace; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
String path = Constants.ZROOT + "/" + iid + Constants.ZTRACERS;
zapDirectory(zoo, path);
private static void zapDirectory(IZooReaderWriter zoo, String path) {
List<String> children = zoo.getChildren(path);
message("Deleting " + path + "/" + child + " from zookeeper");
zoo.recursiveDelete(path + "/" + child, NodeMissingPolicy.SKIP); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
setSource(iterator);
setSource(iterator); | Remove this unused method parameter "hasStart". |
package org.apache.accumulo.cloudtrace.instrument.impl;
import org.apache.accumulo.cloudtrace.instrument.Span;
import org.apache.accumulo.cloudtrace.instrument.Tracer;
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
public class ConcurrencyIT extends ConfigurableMacIT { | Use "Integer.toString" instead. |
if (!migrations.isEmpty())
return 100;
KeyExtent ke = new KeyExtent(ts.extent);
migrationsOut.add(new TabletMigration(ke, e.getKey(), dest));
// We can get some craziness with only 1 tserver, so lets make sure there's always an option!
if (underCapacityTServer.isEmpty())
underCapacityTServer.addAll(numTablets.keySet());
return 100; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
package org.apache.accumulo.test.functional; | Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison. |
public static boolean setTableProperty(String tableId, String property, String value) throws KeeperException, InterruptedException {
if (!isPropertyValid(property, value)) return false;
// create the zk node for per-table properties for this table if it doesn't already exist
String zkTablePath = getTablePath(tableId);
ZooReaderWriter.getInstance().putPersistentData(zkTablePath, new byte[0], NodeExistsPolicy.SKIP);
// create the zk node for this property and set it's data to the specified value
String zPath = zkTablePath + "/" + property;
ZooReaderWriter.getInstance().putPersistentData(zPath, value.getBytes(), NodeExistsPolicy.OVERWRITE);
return true;
}
public static boolean isPropertyValid(String property, String value) {
Property p = Property.getPropertyByKey(property);
if ((p != null && !p.getType().isValidFormat(value)) || !Property.isValidTablePropertyKey(property)) return false;
return true;
}
public static void removeTableProperty(String tableId, String property) throws InterruptedException, KeeperException {
String zPath = getTablePath(tableId) + "/" + property;
ZooReaderWriter.getInstance().recursiveDelete(zPath, NodeMissingPolicy.SKIP);
}
private static String getTablePath(String tablename) {
return ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTABLES + "/" + tablename + Constants.ZTABLE_CONF;
} | 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.
*/
private static final long serialVersionUID = 1L;
public IterationInterruptedException() {
super();
}
public IterationInterruptedException(String msg) {
super(msg);
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
package org.apache.accumulo.server.test.continuous;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class PrintScanTimeHistogram {
public static void main(String[] args) throws Exception {
Histogram<String> srqHist = new Histogram<String>();
Histogram<String> fsrHist = new Histogram<String>();
processFile(System.in, srqHist, fsrHist);
System.out.println();
System.out.println(" *** Single row queries histogram *** ");
System.out.println();
srqHist.print();
System.out.println();
System.out.println(" *** Find start rows histogram *** ");
System.out.println();
fsrHist.print();
}
private static void processFile(InputStream ins, Histogram<String> srqHist, Histogram<String> fsrHist) throws FileNotFoundException, IOException {
String line;
BufferedReader in = new BufferedReader(new InputStreamReader(ins));
while((line = in.readLine()) != null){
try{
String[] tokens = line.split(" ");
String type = tokens[0];
if(type.equals("SRQ")){
long delta = Long.parseLong(tokens[3]);
String point = generateHistPoint(delta);
srqHist.addPoint(point);
}else if(type.equals("FSR")){
long delta = Long.parseLong(tokens[3]);
String point = generateHistPoint(delta);
fsrHist.addPoint(point);
}
}catch(Exception e){
System.err.println("Failed to process line : "+line);
e.printStackTrace();
}
}
in.close();
}
private static String generateHistPoint(long delta) {
String point;
if(delta/1000.0 < .1){
point = String.format("%07.2f", delta/1000.0);
if(point.equals("0000.10")) point = "0000.1x";
} else if(delta/1000.0 < 1.0) {
point = String.format("%06.1fx", delta/1000.0);
if(point.equals("0001.0x")) point = "0001.xx";
} else {
point = String.format("%04.0f.xx", delta/1000.0);
}
return point;
}
} | Return empty string instead. |
import org.apache.accumulo.core.security.tokens.NullToken;
import org.apache.accumulo.core.security.tokens.AuthenticationToken; | 1 duplicated blocks of code must be removed. |
throws ThriftSecurityException, TException {
MetaDataTableScanner s = new MetaDataTableScanner(zki, SystemCredentials.get(), tableRange); | Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable". |
shellState.updateUser(user, new PasswordToken(pass)); | Immediately return this expression instead of assigning it to the temporary variable "connector". |
String[] theList;
static class Watcher implements LoggerWatcher {
public ArrayList<String> added = new ArrayList<String>();
public ArrayList<String> deleted = new ArrayList<String>();
@Override
public void newLogger(String address) {
added.add(address);
}
@Override
public void deadLogger(String address) {
deleted.add(address);
}
Watcher watcher = new Watcher();
class TabletServerLoggers_ extends TabletServerLoggers {
public String[] theList = new String[0];
TabletServerLoggers_() {
super(watcher, AccumuloConfiguration.getDefaultConfiguration());
@Override
public synchronized Map<String,String> getLoggersFromZooKeeper() {
HashMap<String,String> result = new HashMap<String,String>();
for (int i = 0; i < theList.length; i++) {
result.put("" + i, theList[i]);
}
return result;
}
@Test
public void testScanZooKeeperForUpdates() throws Exception {
String[] loggers = {"1.2.3.4:1234", "1.1.1.2:1234", "1.1.1.3:1234",};
TabletServerLoggers_ lgs = new TabletServerLoggers_();
lgs.scanZooKeeperForUpdates();
assertEquals(lgs.getLoggersFromZooKeeper().size(), 0);
lgs.theList = loggers;
lgs.scanZooKeeperForUpdates();
assertEquals(lgs.getLoggersFromZooKeeper().size(), 3);
String[] update = {"1.2.3.4:1234"};
lgs.theList = update;
lgs.scanZooKeeperForUpdates();
assertEquals(lgs.getLoggersFromZooKeeper().size(), 1);
assertEquals(watcher.added.size(), 3);
assertEquals(watcher.deleted.size(), 2);
assertEquals(watcher.deleted, Arrays.asList("1.1.1.3:1234", "1.1.1.2:1234"));
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
Set<Range> ranges = opts.getConnector().tableOperations().splitRangeByTablets(opts.getTableName(), new Range(), opts.maxMaps); | Reorder the modifiers to comply with the Java Language Specification. |
package org.apache.accumulo.examples.mapreduce.bulk;
import java.util.TreeSet;
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.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.hadoop.io.Text;
public class SetupTable {
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableExistsException
{
Connector conn = new ZooKeeperInstance(args[0], args[1]).getConnector(args[2], args[3].getBytes());
if (args.length == 5)
{
// create a basic table
conn.tableOperations().create(args[4]);
}
else if (args.length > 5)
{
// create a table with initial partitions
TreeSet<Text> intialPartitions = new TreeSet<Text>();
for (int i = 5; i < args.length; ++i)
intialPartitions.add(new Text(args[i]));
conn.tableOperations().create(args[4]);
try {
conn.tableOperations().addSplits(args[4], intialPartitions);
} catch (TableNotFoundException e) {
// unlikely
throw new RuntimeException(e);
}
}
else
{
System.err.println("Usage : SetupTable <instance> <zookeepers> <username> <password> <table name> [<split point>{ <split point}]");
}
}
} | Return empty string instead. |
Dataset Card for "techdebt_label"
This dataset was generated from The Technical Debt Dataset created by Lenarduzzi, et al. and the citation is down below.
Dataset Details and Structure
The labels for the dataset were provided by the SonarQube software cited by the paper and matched to the diff in the commit where the message was raised. This diff was then cleaned to only include the lines of code added.
Bias, Risks, and Limitations
Beware of the limited sample size and label variety in the dataset. Also, the queries used to extract this data are still being checked over to ensure correctness.
Recommendations
Changes are constantly being made to this dataset to make it better. Please be aware when you use it.
References
Valentina Lenarduzzi, Nyyti Saarimäki, Davide Taibi. The Technical Debt Dataset. Proceedings for the 15th Conference on Predictive Models and Data Analytics in Software Engineering. Brazil. 2019.
- Downloads last month
- 65