Diff stringlengths 10 2k | Message stringlengths 28 159 |
|---|---|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.examples.simple.filedata.ChunkCombiner;
if (!conn.tableOperations().exists(dataTable)) {
conn.tableOperations().attachIterator(dataTable, new IteratorSetting(1, ChunkCombiner.class));
} | 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.
*/
@SuppressWarnings("all") public class KeyValue implements org.apache.thrift.TBase<KeyValue, KeyValue._Fields>, java.io.Serializable, Cloneable {
@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]*$'. |
import org.junit.Assert; | 6 duplicated blocks of code must be removed. |
log.info("Checking if Zookeeper is available. If this hangs, then you need to make sure zookeeper is running");
if (!zookeeperAvailable()) {
log.fatal("Zookeeper needs to be up and running in order to init. Exiting ...");
return false;
}
/**
* @return
*/
private static boolean zookeeperAvailable() {
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
try {
return zoo.exists("/");
} catch (KeeperException e) {
return false;
} catch (InterruptedException e) {
return false;
}
}
| Either log or rethrow this exception. |
import org.apache.accumulo.core.security.tokens.PasswordToken;
import org.apache.accumulo.core.security.tokens.SecurityToken; | Replace all tab characters in this file by sequences of white-spaces. |
try {
// ACCUMULO-1558 a second import from the same dir should fail, the first import moved the files
client.importTable(creds, "testify2", destDir);
fail();
} catch (Exception e) {}
assertFalse(client.listTables(creds).contains("testify2"));
| 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. |
// there's a little race between getting the children and fetching
// the data. The log can be removed in between.
while (true) {
result.clear();
for (String child : zoo.getChildren(root)) {
LogEntry e = new LogEntry();
try {
e.fromBytes(zoo.getData(root + "/" + child, null));
result.add(e);
} catch (KeeperException.NoNodeException ex) {
continue;
}
}
break; | Either log or rethrow this exception. |
IS_CONFIGURED, PRINCIPAL, TOKEN, TOKEN_CLASS | 3 duplicated blocks of code must be removed. |
client.loadTablet(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock), extent.toThrift());
client.unloadTablet(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock), extent.toThrift(), save);
return client.getTabletServerStatus(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials());
client.halt(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock));
client.fastHalt(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock));
client.flush(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock), tableId, startRow == null ? null : ByteBuffer.wrap(startRow),
client.chop(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock), extent.toThrift());
.splitTablet(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), extent.toThrift(), ByteBuffer.wrap(splitPoint.getBytes(), 0, splitPoint.getLength()));
client.flushTablet(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock), extent.toThrift());
client.compact(Tracer.traceInfo(), SecurityConstants.getThriftSystemCredentials(), lockString(lock), tableId, startRow == null ? null : ByteBuffer.wrap(startRow), | Immediately return this expression instead of assigning it to the temporary variable "ret". |
import org.apache.accumulo.core.security.tokens.UserPassToken;
UserPassToken upt = new UserPassToken(tableUserName, tabUserPass);
conn.securityOperations().createUser(upt);
state.getConnector().securityOperations().createUser(upt);
WalkingSecurity.get(state).createUser(upt);
WalkingSecurity.get(state).createUser(upt); | Immediately return this expression instead of assigning it to the temporary variable "ret". |
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = SecurityHelper.getSystemConnector(state);
String tableUserName = SecurityHelper.getTabUserName(state);
boolean exists = SecurityHelper.getTabUserExists(state);
boolean hasPermission = false;
if (SecurityHelper.getSysPerm(state, SecurityHelper.getSysUserName(state), SystemPermission.DROP_USER)) hasPermission = true;
try {
conn.securityOperations().dropUser(tableUserName);
} catch (AccumuloSecurityException ae) {
switch (ae.getErrorCode()) {
case PERMISSION_DENIED:
if (hasPermission) throw new AccumuloException("Got a security exception when I should have had permission.", ae);
else {
if (exists) {
state.getConnector().securityOperations().dropUser(tableUserName);
SecurityHelper.setTabUserExists(state, false);
for (TablePermission tp : TablePermission.values())
SecurityHelper.setTabPerm(state, tableUserName, tp, false);
for (SystemPermission sp : SystemPermission.values())
SecurityHelper.setSysPerm(state, tableUserName, sp, false);
return;
}
case USER_DOESNT_EXIST:
if (exists) throw new AccumuloException("Got user DNE exception when user should exists.", ae);
else return;
default:
throw new AccumuloException("Got unexpected exception", ae);
}
SecurityHelper.setTabUserExists(state, false);
for (TablePermission tp : TablePermission.values())
SecurityHelper.setTabPerm(state, tableUserName, tp, false);
for (SystemPermission sp : SystemPermission.values())
SecurityHelper.setSysPerm(state, tableUserName, sp, false);
if (!hasPermission) throw new AccumuloException("Didn't get Security Exception when we should have");
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/**
*
*/
package org.apache.accumulo.server.test.randomwalk;
/**
* Tests are extended by users to perform actions on
* accumulo and are a node of the graph
*/
public abstract class Test extends Node {
@Override
public String toString() {
return getClass().getName();
}
} | Return empty string instead. |
import java.nio.ByteBuffer;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.util.ByteBufferUtil;
import org.apache.hadoop.io.Writable;
public class PasswordToken implements AuthenticationToken {
/**
* Constructor for use with {@link Writable}. Call {@link #readFields(DataInput)}.
*/
public PasswordToken() {}
/**
* Constructs a token from a copy of the password. Destroying the argument after construction will not destroy the copy in this token, and destroying this
* token will only destroy the copy held inside this token, not the argument.
*
* Password tokens created with this constructor will store the password as UTF-8 bytes.
*/
public PasswordToken(CharSequence password) {
this.password = password.toString().getBytes(Constants.UTF8);
/**
* Constructs a token from a copy of the password. Destroying the argument after construction will not destroy the copy in this token, and destroying this
* token will only destroy the copy held inside this token, not the argument.
*/
public PasswordToken(byte[] password) {
this.password = Arrays.copyOf(password, password.length);
}
/**
* Constructs a token from a copy of the password. Destroying the argument after construction will not destroy the copy in this token, and destroying this
* token will only destroy the copy held inside this token, not the argument.
*/
public PasswordToken(ByteBuffer password) {
this.password = ByteBufferUtil.toBytes(password);
}
Arrays.fill(password, (byte) 0x00);
return password == null;
return Arrays.equals(password, other.password);
@Override
return new PasswordToken(password); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
cutPoints.add(new Text(Base64.decodeBase64(in.nextLine().getBytes()))); | Remove this unused method parameter "ex". |
import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
Connector conn = SecurityHelper.getSystemConnector(state);
String tableUserName = SecurityHelper.getTabUserName(state);
boolean exists = SecurityHelper.getTabUserExists(state);
boolean hasPermission = false;
if (SecurityHelper.getSysPerm(state, SecurityHelper.getSysUserName(state), SystemPermission.DROP_USER))
hasPermission = true;
SecurityHelper.setTabUserExists(state, false);
for (TablePermission tp : TablePermission.values())
SecurityHelper.setTabPerm(state, tableUserName, tp, false);
for (SystemPermission sp : SystemPermission.values())
SecurityHelper.setSysPerm(state, tableUserName, sp, false);
SecurityHelper.setTabUserExists(state, false);
for (TablePermission tp : TablePermission.values())
SecurityHelper.setTabPerm(state, tableUserName, tp, false);
for (SystemPermission sp : SystemPermission.values())
SecurityHelper.setSysPerm(state, tableUserName, sp, false); | Either log or rethrow this exception. |
@SuppressWarnings("deprecation")
String instanceIDFromFile = ZooKeeperInstance.getInstanceIDFromHdfs(instanceDir);
return cachedInstance = new ZooKeeperInstance(UUID.fromString(instanceIDFromFile), zookeepers); | Extract the assignment out of this expression. |
import java.util.concurrent.TimeUnit;
BatchWriter bw = getConnector().createBatchWriter("bwlt", new BatchWriterConfig().setMaxLatency(2000, TimeUnit.MILLISECONDS)); | Remove this unused private "appendProp" method. |
* Test to see if the instance can load the given class as the given type. This check does not consider per table classpaths, see
* {@link TableOperations#testClassLoad(String, String, String)} | Either log or rethrow this exception. |
package org.apache.accumulo.test.randomwalk.shard;
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. |
timeOut = 0; | Use isEmpty() to check whether the collection is empty or not. |
private static final long serialVersionUID = 1L;
public BadArgumentException(String desc, String badarg, int index) {
super(desc, badarg, index);
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
if (!hasSystemPermission(credentials, credentials.user, SystemPermission.ALTER_USER)) {
Authorizations creatorAuths = getUserAuthorizations(credentials, credentials.user);
for (byte[] auth : authorizations.getAuthorizations())
if (!creatorAuths.contains(auth)) {
log.info("User " + credentials.user + " attempted to create a user " + user + " with authorization " + new String(auth) + " they did not have");
throw new AccumuloSecurityException(credentials.user, SecurityErrorCode.BAD_AUTHORIZATIONS);
}
}
| Remove the literal "false" boolean value. |
public static void setInputInfo(Configuration conf, String user, byte[] passwd, String table, Authorizations auths) {
try {
FileSystem fs = FileSystem.get(conf);
Path file = new Path(fs.getWorkingDirectory(), conf.get("mapred.job.name") + System.currentTimeMillis() + ".pw");
conf.set(PASSWORD_PATH, file.toString());
FSDataOutputStream fos = fs.create(file, false);
fs.setPermission(file, new FsPermission(FsAction.ALL, FsAction.NONE, FsAction.NONE));
fs.deleteOnExit(file);
byte[] encodedPw = Base64.encodeBase64(passwd);
fos.writeInt(encodedPw.length);
fos.write(encodedPw);
fos.close();
DistributedCache.addCacheFile(file.toUri(), conf);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} | Define and throw a dedicated exception instead of using a generic one. |
/**
* Deletes the ranges specified by {@link #setRanges}.
*
* @throws MutationsRejectedException
* this can be thrown when deletion mutations fail
* @throws TableNotFoundException
* when the table does not exist
*/
/**
* Releases any resources.
*/ | Move this constructor to comply with Java Code Conventions. |
timestampOpt = new Option("ts", "timestamp", true, "timestamp to use for insert"); | Reduce this switch case number of lines from 8 to at most 5, for example by extracting code into methods. |
/*
* 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 class ActiveCompaction implements org.apache.thrift.TBase<ActiveCompaction, ActiveCompaction._Fields>, java.io.Serializable, Cloneable {
@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]*$'. |
import org.apache.accumulo.core.security.tokens.PasswordToken;
import org.apache.accumulo.core.security.tokens.SecurityToken; | Replace all tab characters in this file by sequences of white-spaces. |
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.TimerTask;
import org.apache.accumulo.server.util.time.SimpleTimer;
monitorSwappiness();
/**
*
*/
public static void monitorSwappiness() {
SimpleTimer.getInstance().schedule(new TimerTask() {
@Override
public void run() {
try {
File swappiness = new File("/proc/sys/vm/swappiness");
if (swappiness.exists() && swappiness.canRead()) {
InputStream is = new FileInputStream("/proc/sys/vm/swappiness");
try {
byte[] buffer = new byte[10];
int bytes = is.read(buffer);
String setting = new String(buffer, 0, bytes);
if (bytes > 0 && Integer.parseInt(setting) > 0) {
log.warn("System swappiness setting is greater than zero (" + setting + ") which can cause time-sensitive operations to be delayed. "
+ " Accumulo is time sensitive because it needs to maintain distributed lock agreement.");
}
} finally {
is.close();
}
}
} catch (Throwable t) {
log.error(t, t);
}
}
}, 1000, 10 * 1000);
}
| Reduce this anonymous class number of lines from 26 to at most 20, or make it a named class. |
*
*
*
*
*
*
*
*
* | Replace all tab characters in this file by sequences of white-spaces. |
AccumuloInputFormat.setConnectorInfo(job, user, new PasswordToken(pass)); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
newText.append(suffix.getBytes(), 0, suffix.length()); | 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.
*/
private static final long serialVersionUID = 1L;
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
tableOpt = new Option(Shell.tableOption, "table", true, "table to set the iterator on");
classnameTypeOpt = new Option("class", "class-name", true, "a java class that implements SortedKeyValueIterator");
aggTypeOpt = new Option("agg", "aggregator", false, "an aggregating iterator");
regexTypeOpt = new Option("regex", "regular-expression", false, "a regex matching iterator");
versionTypeOpt = new Option("vers", "version", false, "a versioning iterator");
reqvisTypeOpt = new Option("reqvis", "require-visibility", false, "an iterator that omits entries with empty visibilities");
ageoffTypeOpt = new Option("ageoff", "ageoff", false, "an aging off iterator"); | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ChoppedColumnFamily;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.LogColumnFamily;
TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
scanner.fetchColumnFamily(TabletsSection.FutureLocationColumnFamily.NAME);
scanner.fetchColumnFamily(LogColumnFamily.NAME);
scanner.fetchColumnFamily(ChoppedColumnFamily.NAME);
if (cf.compareTo(TabletsSection.FutureLocationColumnFamily.NAME) == 0) {
} else if (cf.compareTo(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) {
} else if (cf.compareTo(LogColumnFamily.NAME) == 0) {
} else if (cf.compareTo(TabletsSection.LastLocationColumnFamily.NAME) == 0) {
} else if (cf.compareTo(ChoppedColumnFamily.NAME) == 0) {
} else if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(cf, cq)) { | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
@Override
@Parameter(names = "--column", required = true)
AccumuloInputFormat.fetchColumns(job, Collections.singleton(new Pair<Text,Text>(cf, cq))); | Move this variable to comply with Java Code Conventions. |
if (entry != null)
count++;
if (entry != null)
count++; | Remove this call to "exit" or ensure it is really required. |
package logic;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Counters;
import org.apache.hadoop.mapreduce.StatusReporter;
public class StandaloneStatusReporter extends StatusReporter {
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++;
}
} | Return empty string instead. |
@Deprecated | Remove this unused method parameter "ex". |
import org.apache.accumulo.server.security.SystemCredentials;
MetadataTableUtil.deleteTable(cloneInfo.tableId, false, SystemCredentials.get().getAsThrift(), environment.getMasterLock());
MetadataTableUtil.deleteTable(cloneInfo.tableId, false, SystemCredentials.get().getAsThrift(), environment.getMasterLock());
AuditedSecurityOperation.getInstance().grantTablePermission(SystemCredentials.get().getAsThrift(), cloneInfo.user, cloneInfo.tableId, permission);
AuditedSecurityOperation.getInstance().deleteTable(SystemCredentials.get().getAsThrift(), cloneInfo.tableId); | Move this constructor to comply with Java Code Conventions. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
assertEquals(0, shell.getExitCode());
output.clear();
shell.execCommand("du -h", false, false);
String o = output.get();
System.out.println("XX" + o + "XX");
assertTrue(o.matches(".*\\s26[4-6]B\\s\\[t\\]\\n")); // for some reason, there's 1-2 bytes of fluctuation | Move this variable to comply with Java Code Conventions. |
import org.apache.accumulo.core.security.Credentials;
public TabletLocation locateTablet(Credentials credentials, Text row, boolean skipRow, boolean retry) throws AccumuloException, AccumuloSecurityException,
TabletLocation ret = locator.locateTablet(credentials, row, skipRow, retry);
public <T extends Mutation> void binMutations(Credentials credentials, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures)
throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
locator.binMutations(credentials, mutations, binnedMutations, failures);
public List<Range> binRanges(Credentials credentials, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges) throws AccumuloException,
List<Range> ret = locator.binRanges(credentials, ranges, binnedRanges); | Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable". |
long seeks = 0;
table.scanRate += tablet.scanRate();
seeks += tablet.getNumSeeks();
result.lookups = seeks; | Use isEmpty() to check whether the collection is empty or not. |
protected byte buf[]; // the borrowed buffer
protected int count = 0; // bytes used in buffer.
// Constructor
public SimpleBufferedOutputStream(OutputStream out, byte[] buf) {
super(out);
this.buf = buf;
}
private void flushBuffer() throws IOException {
if (count > 0) {
out.write(buf, 0, count);
count = 0;
}
@Override
public void write(int b) throws IOException {
if (count >= buf.length) {
flushBuffer();
buf[count++] = (byte) b;
}
@Override
public void write(byte b[], int off, int len) throws IOException {
if (len >= buf.length) {
flushBuffer();
out.write(b, off, len);
return;
if (len > buf.length - count) {
flushBuffer();
System.arraycopy(b, off, buf, count, len);
count += len;
}
@Override
public synchronized void flush() throws IOException {
flushBuffer();
out.flush();
}
// Get the size of internal buffer being used.
public int size() {
return count;
} | 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.
*/
public void setScanIterators(int priority, String iteratorClass, String iteratorName) {}
public void addScanIterator(IteratorSetting cfg) {}
public void setScanIteratorOption(String iteratorName, String key, String value) {}
public void updateScanIteratorOption(String iteratorName, String key, String value) {}
public void setupRegex(String iteratorName, int iteratorPriority) throws IOException {}
public void setRowRegex(String regex) {}
public void setColumnFamilyRegex(String regex) {}
public void setColumnQualifierRegex(String regex) {}
public void setValueRegex(String regex) {}
public void fetchColumnFamily(Text col) {}
public void fetchColumn(Text colFam, Text colQual) {}
public void clearColumns() {}
public void clearScanIterators() {}
public void setTimeOut(int timeOut) {}
public void setRange(Range range) {}
public Iterator<Entry<Key,Value>> iterator() {
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/**
* @since 1.5.0
*/ | Move this constructor to comply with Java Code Conventions. |
public RandomLoggerStrategy() {}
public RandomLoggerStrategy(TabletServer tserver) {}
@Override
public Set<String> getLoggers(Set<String> allLoggers) {
List<String> copy = new ArrayList<String>(allLoggers);
Collections.shuffle(copy);
return new HashSet<String>(copy.subList(0, min(copy.size(), getNumberOfLoggersToUse())));
}
@Override
public void preferLoggers(Set<String> preference) {
// ignored
}
| 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. |
return new ColumnUpdate(cf, cq, cv, hasts, ts, deleted, val);
if (!Arrays.equals(row, m.getRow()))
return false;
List<ColumnUpdate> oldcus = this.getUpdates();
List<ColumnUpdate> newcus = m.getUpdates();
if (oldcus.size() != newcus.size())
return false;
for (int i = 0; i < newcus.size(); i++) {
ColumnUpdate oldcu = oldcus.get(i);
ColumnUpdate newcu = newcus.get(i);
if (!oldcu.equals(newcu))
return false;
return new TMutation(java.nio.ByteBuffer.wrap(row), java.nio.ByteBuffer.wrap(data), ByteBufferUtil.toByteBuffers(values), entries); | Remove this unused method parameter "timestamp". |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Remove this unused private "appendProp" method. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
@Override
shellState.updateUser(CredentialHelper.create(user, new PasswordToken(pass), shellState.getConnector().getInstance().getInstanceID())); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.junit.After;
static JobContext job;
static TaskAttemptContext tac;
static Path f = null;
Path file = new Path(System.getenv("ACCUMULO_HOME")+"/target/");
f = new Path(file,"_temporary");
job.getConfiguration().set("mapred.output.dir", file.toString());
@After
public void teardown() throws IOException
{
if (f!= null && f.getFileSystem(job.getConfiguration()).exists(f))
{
f.getFileSystem(job.getConfiguration()).delete(f, true);
}
}
@Test
public void testEmptyWrite() throws IOException, InterruptedException {
handleWriteTests(false);
}
@Test
public void testRealWrite() throws IOException, InterruptedException {
handleWriteTests(true);
}
public void handleWriteTests(boolean content) throws IOException, InterruptedException {
AccumuloFileOutputFormat afof = new AccumuloFileOutputFormat();
RecordWriter<Key, Value> rw = afof.getRecordWriter(tac);
if (content)
rw.write(new Key("Key"), new Value("".getBytes()));
Path file = afof.getDefaultWorkFile(tac, ".rf");
System.out.println(file);
rw.close(tac);
if (content)
assertTrue(file.getFileSystem(job.getConfiguration()).exists(file));
else
assertFalse(file.getFileSystem(job.getConfiguration()).exists(file));
file.getFileSystem(tac.getConfiguration()).delete(file.getParent(), true);
}
| Refactor this method to throw at most one checked exception instead of: java.io.IOException, java.lang.InterruptedException |
public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String> tables, FileSystem fs, Connector conn, boolean humanReadable)
throws TableNotFoundException, IOException {
}, humanReadable);
public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String> tables, FileSystem fs, Connector conn, Printer printer,
boolean humanReadable) throws TableNotFoundException, IOException {
for (Entry<TreeSet<String>,Long> entry : usage.entrySet()) {
String valueFormat = humanReadable ? "%s" : "%,24d";
Object value = humanReadable ? humanReadableBytes(entry.getValue()) : entry.getValue();
printer.print(String.format(valueFormat + " %s", value, entry.getKey()));
}
static final String[] SUFFIXES = {"K", "M", "G", "T", "P", "E", "Z"};
public static String humanReadableBytes(long bytes) {
if (bytes < 1024) return String.format("%4dB", bytes);
int exp = (int) (Math.log(bytes) / Math.log(1024));
String suffix = SUFFIXES[exp-1];
double val = bytes / Math.pow(1024, exp);
return String.format(val >= 1000 ? "%4.0f%s" : " %3.1f%s", val, suffix);
} | Move this variable to comply with Java Code Conventions. |
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
Class<? extends Constraint> clazz = AccumuloVFSClassLoader.loadClass(className, Constraint.class); | Remove this unused private "appendProp" method. |
if (ret == 1)
return oneByte[0] & 0xff;
if (n == 0)
return -1;
if (mark < 0)
throw new IOException("Resetting to invalid mark"); | 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. |
* @param portHintProperty
* @param portSearchProperty
* @param minThreadProperty
* @param timeBetweenThreadChecksProperty | Either log or rethrow this exception. |
for (Entry<String,String> entry : ServerConfiguration.getSiteConfiguration()) { | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
@Test(timeout = 60 * 1000) | Either log or rethrow this exception. |
import org.apache.accumulo.core.security.Authorizations;
super(conn.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY), Constants.METADATA_KEYSPACE, true, true);
Scanner ds = conn.createScanner(Constants.METADATA_TABLE_NAME, Authorizations.EMPTY); | Remove this unused method parameter "range". |
if (plan == null || plan.inputFiles.isEmpty()) | Replace this if-then-else statement by a single return statement. |
package org.apache.accumulo.core.iterators.aggregation.conf;
import junit.framework.TestCase;
import org.apache.accumulo.core.iterators.conf.PerColumnIteratorConfig;
import org.apache.hadoop.io.Text;
@SuppressWarnings("deprecation")
public class AggregatorConfigurationTest extends TestCase{
public void testBinary(){
Text colf = new Text();
Text colq = new Text();
for(int i = 0; i < 256; i++){
colf.append(new byte[]{(byte)i}, 0, 1);
colq.append(new byte[]{(byte)(255-i)}, 0, 1);
}
runTest(colf, colq);
runTest(colf);
}
public void testBasic(){
runTest(new Text("colf1"), new Text("cq2"));
runTest(new Text("colf1"));
}
private void runTest(Text colf) {
String encodedCols;
PerColumnIteratorConfig ac3 = new PerColumnIteratorConfig(colf, "com.foo.SuperAgg");
encodedCols = ac3.encodeColumns();
PerColumnIteratorConfig ac4 = PerColumnIteratorConfig.decodeColumns(encodedCols, "com.foo.SuperAgg");
assertEquals(colf, ac4.getColumnFamily());
assertNull(ac4.getColumnQualifier());
}
private void runTest(Text colf, Text colq) {
PerColumnIteratorConfig ac = new PerColumnIteratorConfig(colf, colq, "com.foo.SuperAgg");
String encodedCols = ac.encodeColumns();
PerColumnIteratorConfig ac2 = PerColumnIteratorConfig.decodeColumns(encodedCols, "com.foo.SuperAgg");
assertEquals(colf, ac2.getColumnFamily());
assertEquals(colq, ac2.getColumnQualifier());
}
} | Return empty string instead. |
if (entry == null)
return;
if (numSearchTerms < 2)
numSearchTerms = 2;
if (!sawDocID)
throw new Exception("Did not see doc " + docID + " in index. terms:" + searchTerms + " " + indexTableName + " " + dataTableName);
if (!iter.hasNext())
return null; | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.core.iterators.user.WholeRowIterator;
assertEquals("org.apache.accumulo.core.iterators.user.WholeRowIterator", setting.getIteratorClass()); | Remove the literal "false" boolean value. |
package org.apache.accumulo.server.upgrade;
import org.apache.accumulo.core.util.CachedConfiguration;
import org.apache.accumulo.server.ServerConstants;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class UpdateVersion {
public static void main(String[] args) throws Exception {
Configuration conf = CachedConfiguration.getInstance();
FileSystem fs = FileSystem.get(conf);
Path location = ServerConstants.getDataVersionLocation();
fs.delete(new Path(location, "2"), true);
fs.mkdirs(new Path(location, "3"));
}
} | Return empty string instead. |
if (!found.equals(expected))
throw new Exception("Found and expected differ " + found + " " + expected); | Remove this call to "exit" or ensure it is really required. |
@Test
public void testVisibilityEvaluator() throws VisibilityParseException {
VisibilityEvaluator ct = new VisibilityEvaluator(ByteArraySet.fromStrings("one", "two", "three", "four"));
// test for and
assertTrue("'and' test", ct.evaluate(new ColumnVisibility("one&two")));
// test for or
assertTrue("'or' test", ct.evaluate(new ColumnVisibility("foor|four")));
// test for and and or
assertTrue("'and' and 'or' test", ct.evaluate(new ColumnVisibility("(one&two)|(foo&bar)")));
// test for false negatives
for (String marking : new String[] {"one", "one|five", "five|one", "(one)", "(one&two)|(foo&bar)", "(one|foo)&three", "one|foo|bar", "(one|foo)|bar",
"((one|foo)|bar)&two"}) {
assertTrue(marking, ct.evaluate(new ColumnVisibility(marking)));
}
// test for false positives
for (String marking : new String[] {"five", "one&five", "five&one", "((one|foo)|bar)&goober"}) {
assertFalse(marking, ct.evaluate(new ColumnVisibility(marking)));
}
// test missing separators; these should throw an exception
for (String marking : new String[] {"one(five)", "(five)one", "(one)(two)", "a|(b(c))"}) {
try {
ct.evaluate(new ColumnVisibility(marking));
fail(marking + " failed to throw");
} catch (Throwable e) {
// all is good
}
}
// test unexpected separator
for (String marking : new String[] {"&(five)", "|(five)", "(five)&", "five|", "a|(b)&", "(&five)", "(five|)"}) {
try {
ct.evaluate(new ColumnVisibility(marking));
fail(marking + " failed to throw");
} catch (Throwable e) {
// all is good
}
}
// test mismatched parentheses
for (String marking : new String[] {"(", ")", "(a&b", "b|a)"}) {
try {
ct.evaluate(new ColumnVisibility(marking));
fail(marking + " failed to throw");
} catch (Throwable e) {
// all is good
}
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
package org.apache.accumulo.server.util;
import java.net.InetSocketAddress;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.server.conf.ServerConfiguration;
public class AddressUtil {
static public InetSocketAddress parseAddress(String address, Property portDefaultProperty) {
final int dfaultPort = ServerConfiguration.getSystemConfiguration().getPort(Property.TSERV_CLIENTPORT);
return org.apache.accumulo.core.util.AddressUtil.parseAddress(address, dfaultPort);
}
} | Return empty string instead. |
// Scanners will default to fetching 3 batches of Key/Value pairs before asynchronously
// fetching the next batch.
public static final long SCANNER_DEFAULT_READAHEAD_THRESHOLD = 3l;
| Move this constructor to comply with Java Code Conventions. |
tpc.proxy().setProperty(userpass, "test.systemprop", "whistletips");
assertEquals(tpc.proxy().getSystemConfiguration(userpass).get("test.systemprop"), "whistletips");
tpc.proxy().removeProperty(userpass, "test.systemprop");
assertNull(tpc.proxy().getSystemConfiguration(userpass).get("test.systemprop"));
assertTrue(tpc.proxy().testClassLoad(userpass, "org.apache.accumulo.core.iterators.user.RegExFilter", | 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. |
if (res != 0)
System.exit(res); | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.server.security.SystemCredentials;
final Connector connector = new ZooKeeperInstance("acu14", "localhost").getConnector(SystemCredentials.get().getPrincipal(), SystemCredentials.get()
.getToken()); | Move this constructor to comply with Java Code Conventions. |
log.warn(configFile + " not found on classpath", new Throwable()); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public interface Formatter extends Iterator<String> {
public void initialize(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
protected final TransactionWatcher transactionWatcher; | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.server.fs.VolumeManager;
VolumeManager getFileSystem();
public DfsLogger(ServerResources conf, String logger, Path filename) throws IOException {
this.logPath = filename;
public static FSDataInputStream readHeader(VolumeManager fs, Path path, Map<String,String> opts) throws IOException {
VolumeManager fs = conf.getFileSystem();
logPath = new Path(fs.choose(ServerConstants.getWalDirs()) + "/" + logger + "/" + filename);
replication = fs.getDefaultReplication(logPath);
logFile = fs.createSyncable(logPath, 0, replication, blockSize);
logFile = fs.create(logPath, true, 0, replication, blockSize);
return logPath.toString(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import java.util.regex.Pattern;
import org.junit.Assert;
@SuppressWarnings("deprecation")
@Test
public void testRegex() throws Exception {
MockInstance mockInstance = new MockInstance("testmapinstance");
Connector c = mockInstance.getConnector("root", new byte[] {});
c.tableOperations().create("testtable3");
BatchWriter bw = c.createBatchWriter("testtable3", 10000L, 1000L, 4);
for (int i = 0; i < 100; i++) {
Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
bw.addMutation(m);
}
bw.close();
JobContext job = new JobContext(new Configuration(), new JobID());
AccumuloInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "testtable3", new Authorizations());
AccumuloInputFormat.setMockInstance(job.getConfiguration(), "testmapinstance");
final String regex = ".*1.*";
AccumuloInputFormat.setRegex(job, RegexType.ROW, regex);
AccumuloInputFormat input = new AccumuloInputFormat();
RangeInputSplit ris = new RangeInputSplit();
TaskAttemptContext tac = new TaskAttemptContext(job.getConfiguration(), new TaskAttemptID());
RecordReader<Key,Value> rr = input.createRecordReader(ris, tac);
rr.initialize(ris, tac);
Pattern p = Pattern.compile(regex);
while (rr.nextKeyValue()) {
Assert.assertTrue( p.matcher( rr.getCurrentKey().getRow().toString()).matches());
}
} | Define and throw a dedicated exception instead of using a generic one. |
* Autogenerated by Thrift Compiler (0.9.0)
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
// check for sub-struct validity | Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'. |
@Test(timeout = 30 * 1000) | Either log or rethrow this exception. |
import org.apache.accumulo.core.security.thrift.ThriftSecurityException; | 1 duplicated blocks of code must be removed. |
import java.util.ArrayList;
import java.util.List;
import org.apache.accumulo.server.cli.ClientOpts;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import com.beust.jcommander.Parameter;
static class Opts extends ClientOpts {
@Parameter(description=" <table> { <table> ... } ")
List<String> tables = new ArrayList<String>();
}
Opts opts = new Opts();
opts.parseArgs(TableDiskUsage.class.getName(), args);
Connector conn = opts.getConnector();
org.apache.accumulo.core.util.TableDiskUsage.printDiskUsage(DefaultConfiguration.getInstance(), opts.tables, fs, conn); | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.server.fs.VolumeManager;
import org.apache.accumulo.server.fs.VolumeManagerImpl;
VolumeManager fs = VolumeManagerImpl.get();
MultiReader input = new MultiReader(fs, path); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
if (!scanColumns)
return true;
if (columnFamilies.contains(key.getColumnFamilyData()))
return true; | Remove this call to "exit" or ensure it is really required. |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.core.util.shell.commands.EscapeTokenizer;
| 2 duplicated blocks of code must be removed. |
@Override
public void visit(State state, Properties props) throws Exception {
state.getMultiTableBatchWriter().flush();
log.debug("Committed " + state.getInteger("numWrites") + " writes. Total writes: " + state.getInteger("totalWrites"));
state.set("numWrites", new Integer(0));
}
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
result.append(String.format(" %12s:%s%n", "name", span.description));
result.append(String.format(" %12s:%s%n", "trace", Long.toHexString(span.traceId)));
result.append(String.format(" %12s:%s%n", "loc", span.svc + "@" + span.sender));
result.append(String.format(" %12s:%s%n", "span", Long.toHexString(span.spanId)));
result.append(String.format(" %12s:%s%n", "parent", Long.toHexString(span.parentId)));
result.append(String.format(" %12s:%s%n", "start", dateFormatter.format(span.start)));
result.append(String.format(" %12s:%s%n", "ms", span.stop - span.start));
result.append(String.format(" %12s:%s%n", entry.getKey(), entry.getValue()));
result.append(String.format(" %-12s:%d%n", "timestamp", next.getKey().getTimestamp())); | Use isEmpty() to check whether the collection is empty or not. |
import junit.framework.TestCase;
| Replace all tab characters in this file by sequences of white-spaces. |
if (isTracing())
return new TraceRunnable(Trace.currentTrace(), runnable); | Remove this call to "exit" or ensure it is really required. |
package org.apache.accumulo.core.util.shell.commands;
public class InfoCommand extends AboutCommand {
} | Return empty string instead. |
import java.nio.charset.Charset;
private static final Charset utf8 = Charset.forName("UTF8");
shellState.getConnector().securityOperations().createUser(user, password.getBytes(utf8), authorizations); | Move this variable to comply with Java Code Conventions. |
import java.nio.ByteBuffer;
import org.apache.accumulo.core.security.thrift.Credentials;
shellState.updateUser(new Credentials(user, ByteBuffer.wrap(pass), shellState.getConnector().getInstance().getInstanceID())); | 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.
*/ | Remove this unused private "appendProp" method. |
scanOptColumns.setArgName("<columnfamily>[:<columnqualifier>]{,<columnfamily>[:<columnqualifier>]}"); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.