Diff
stringlengths
10
2k
Message
stringlengths
28
159
* @param assignments * @param assignments * @param tablets
Either log or rethrow this exception.
if (iterators != null) { for (PIteratorSetting is : iterators) { result.add(getIteratorSetting(is)); } pscan.table = scan.getTable(); e.getTableId().toString(), e.getTableId().toString(), result.add(pcomp); public void securityOperations_changeUserAuthorizations(UserPass userpass, String user, Set<ByteBuffer> authorizations) throws AccumuloException, Set<String> auths = new HashSet<String>(); for (ByteBuffer auth : authorizations) { auths.add(ByteBufferUtil.toString(auth)); } getConnector(userpass).securityOperations().changeUserAuthorizations(user, new Authorizations(auths.toArray(new String[0]))); public String createScanner(UserPass userpass, String tableName, Set<ByteBuffer> authorizations, List<PIteratorSetting> iterators, PRange prange) throws TException { if (iterators != null) { for (PIteratorSetting iter : iterators) { IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(), iter.getIteratorClass(), iter.getProperties()); scanner.addScanIterator(is); } public String createBatchScanner(UserPass userpass, String tableName, Set<ByteBuffer> authorizations, List<PIteratorSetting> iterators, List<PRange> pranges) if (iterators != null) { for (PIteratorSetting iter: iterators) { IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(), iter.getIteratorClass(), iter.getProperties()); scanner.addScanIterator(is); } try { while (batchScanner.hasNext() && numRead < k) { Map.Entry<Key,Value> next = batchScanner.next(); ret.addToResults(new PKeyValue(Util.toThrift(next.getKey()), ByteBuffer.wrap(next.getValue().get()))); numRead++; } ret.setMore(numRead == k); } catch (Exception ex) { close_scanner(scanner); throw new TException(ex);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** snappy codec **/ public static final String COMPRESSION_SNAPPY = "snappy"; * <li>"snappy" - Snappy compression
Immediately return this expression instead of assigning it to the temporary variable "bos2".
import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.client.BatchWriterConfig; import org.apache.accumulo.core.security.tokens.UserPassToken; Connector conn = instance.getConnector(new UserPassToken("root", "")); BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig().setMaxMemory(1000000l).setMaxLatency(100l, TimeUnit.SECONDS).setMaxWriteThreads(5)); Connector conn = instance.getConnector(new UserPassToken("root", "")); BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig().setMaxMemory(1000000l).setMaxLatency(100l, TimeUnit.SECONDS).setMaxWriteThreads(5)); Connector conn = instance.getConnector(new UserPassToken("root", "")); BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig().setMaxMemory(1000000l).setMaxLatency(100l, TimeUnit.SECONDS).setMaxWriteThreads(5));
Immediately return this expression instead of assigning it to the temporary variable "ret".
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
private long entriesRead; private long entriesWritten; private long fileSize; CompactionStats(long er, long ew) { this.setEntriesRead(er); this.setEntriesWritten(ew); } public CompactionStats() {} private void setEntriesRead(long entriesRead) { this.entriesRead = entriesRead; } public long getEntriesRead() { return entriesRead; } private void setEntriesWritten(long entriesWritten) { this.entriesWritten = entriesWritten; } public long getEntriesWritten() { return entriesWritten; } public void add(CompactionStats mcs) { this.entriesRead += mcs.entriesRead; this.entriesWritten += mcs.entriesWritten; } public void setFileSize(long fileSize) { this.fileSize = fileSize; } public long getFileSize() { return this.fileSize; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.security.tokens.UserPassToken; * @deprecated since 1.5, use {@link UserPassToken} instead
Remove this empty statement.
for (Entry<String,String> optEntry : setting.getOptions().entrySet()) {
Refactor this code to not nest more than 3 if/for/while/switch/try statements.
String tableName = getTableNames(1)[0];
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.core.util.interpret; import org.apache.hadoop.io.Text; /** * A simple interface for creating shell plugins that translate the range and column arguments for the shell's scan command. */ public interface ScanInterpreter { public Text interpretRow(Text row); public Text interpretBeginRow(Text row); public Text interpretEndRow(Text row); public Text interpretColumnFamily(Text cf); public Text interpretColumnQualifier(Text cq); }
Return empty string instead.
import java.util.ArrayList; import org.apache.accumulo.core.Constants; tableNames = new ArrayList<String>(tableNames); tableNames.add(Constants.METADATA_TABLE_NAME);
Use "Integer.toString" instead.
import org.apache.accumulo.core.security.tokens.AuthenticationToken;
1 duplicated blocks of code must be removed.
package org.apache.accumulo.examples.wikisearch.iterator; import org.apache.accumulo.examples.wikisearch.parser.EventFields; import org.apache.accumulo.examples.wikisearch.parser.QueryEvaluator;
Rename "table" which hides the field declared at line 107.
import java.nio.CharBuffer; if (properties.containsKey("password")){ // encode() kicks back a C-string, which is not compatible with the old passwording system this.password = new byte[properties.get("password").length]; Constants.UTF8.encode(CharBuffer.wrap(properties.get("password"))).get(this.password, 0, this.password.length); }else
Override the "equals" method in this class.
/* * 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.
@Test(timeout=60*1000)
Either log or rethrow this exception.
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("sum"); io.setDescription("SummingCombiner interprets Values as Longs and adds them together. A variety of encodings (variable length, fixed length, or string) are available"); return io; }
Move this variable to comply with Java Code Conventions.
import java.util.NoSuchElementException;
Use "Integer.toString" instead.
return "prints how much space is used by files referenced by a table. When multiple tables are specified it prints how much space is used by files shared between tables, if any.";
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.
if (SecurityHelper.getSysPerm(state, username, SystemPermission.DROP_TABLE) || SecurityHelper.getTabPerm(state, username, TablePermission.DROP_TABLE)) hasPermission = true; if (hasPermission) throw new AccumuloException("Got a security exception when I should have had permission.", ae); if (exists) throw new TableExistsException(null, tableName, "Got a TableNotFOundException but it should have existed", tnfe); else return; if (!hasPermission) throw new AccumuloException("Didn't get Security Exception when we should have");
Remove this call to "exit" or ensure it is really required.
return "clones a table"; excludePropsOption = new Option("e", "exclude", true, "exclude properties that should not be copied from source table. Expects <prop>{,<prop>}"); }
Replace all tab characters in this file by sequences of white-spaces.
/** * Reads all data between two rows; all data after a given row; or all data in a table, depending on the number of arguments given. */
Replace this use of System.out or System.err by a logger.
AccumuloOutputFormat.setOutputInfo(job.getConfiguration(), args[0], args[1].getBytes(), true, args[5]); AccumuloOutputFormat.setZooKeeperInstance(job.getConfiguration(), args[3], args[4]);
This block of commented-out lines of code should be removed.
if (log.isTraceEnabled()) log.trace(event); if (log.isTraceEnabled()) log.trace("Zoo keeper connection disconnected, clearing cache"); if (log.isTraceEnabled()) log.trace("Zoo keeper connection expired, clearing cache"); if (sleepTime < 10000) sleepTime = (int) (sleepTime + sleepTime * Math.random()); if (childrenCache.containsKey(zPath)) return; if (cache.containsKey(zPath)) return; if (log.isTraceEnabled()) log.trace("zookeeper did not contain " + zPath); if (log.isTraceEnabled()) log.trace("zookeeper contained " + zPath + " " + (data == null ? null : new String(data))); if (log.isTraceEnabled()) log.trace("putting " + zPath + " " + (data == null ? null : new String(data)) + " in cache"); if (log.isTraceEnabled()) log.trace("removing " + zPath + " from cache"); if (path.startsWith(zPath)) i.remove(); if (path.startsWith(zPath)) i.remove(); if (path.startsWith(zPath)) i.remove();
Remove this call to "exit" or ensure it is really required.
if (m.size() > 0) bw.addMutation(m);
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.core.client.IteratorSetting.Column; protected static final String COLUMNS_OPTION = "columns"; "<col fam>[:<col qual>]{,<col fam>[:<col qual>]} escape non-alphanum chars using %<hex>."), * a list of columns to encode as the value for the combiner column configuration public static void setColumns(IteratorSetting is, List<IteratorSetting.Column> columns) {
Remove the literal "true" boolean value.
import java.util.EnumSet; import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; import org.apache.accumulo.minicluster.MiniAccumuloConfig; import org.junit.Test; public class ConcurrencyIT extends MacTest { SlowIterator.setSleepTime(slow, time); public void configure(MiniAccumuloConfig cfg) { cfg.setSiteConfig(Collections.singletonMap(Property.TSERV_MAJC_DELAY.getKey(), "1")); @Test(timeout=30*1000) Connector c = getConnector(); c.tableOperations().create("cct"); IteratorSetting is = new IteratorSetting(10, SlowIterator.class); SlowIterator.setSleepTime(is, 50); c.tableOperations().attachIterator("cct", is, EnumSet.of(IteratorScope.minc, IteratorScope.majc)); c.tableOperations().setProperty("cct", Property.TABLE_MAJC_RATIO.getKey(), "1.0");
Either log or rethrow this exception.
public void update(String writer, Map<ByteBuffer,List<ColumnUpdate>> cells) throws org.apache.thrift.TException; public void update(String writer, Map<ByteBuffer,List<ColumnUpdate>> cells) throws org.apache.thrift.TException super(client, protocolFactory, transport, resultHandler, true); public void getResult() throws org.apache.thrift.TException { return true; public org.apache.thrift.TBase getResult(I iface, update_args args) throws org.apache.thrift.TException { iface.update(args.writer, args.cells); return null;
Rename this class to remove "Exception" or correct its inheritance.
import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; MetadataTableUtil.updateTabletPrevEndRow(ke, CredentialHelper.create(opts.principal, opts.getToken(), opts.instance)); scanner.setRange(MetadataSchema.TabletsSection.getRange()); TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner); scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME); if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) { } else if (colf.equals(TabletsSection.CurrentLocationColumnFamily.NAME)) { Writer t = MetadataTableUtil.getMetadataTable(CredentialHelper.create(opts.principal, opts.getToken(), opts.instance));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private static final Map<String,TableConfiguration> tableInstances = new HashMap<String,TableConfiguration>(1);
Move this variable to comply with Java Code Conventions.
private static class MyMapper extends Mapper<Key,Value,Text,NullWritable> { Text k = new Text(); public void map(Key key, Value value, Context context) throws IOException, InterruptedException { context.write(key.getRow(k), NullWritable.get()); } private static class MyReducer extends Reducer<Text,NullWritable,Text,Text> { public enum Count { uniqueRows public void reduce(Text key, Iterable<NullWritable> values, Context context) throws IOException { context.getCounter(Count.uniqueRows).increment(1); } } @Override public int run(String[] args) throws IOException, InterruptedException, ClassNotFoundException { if (args.length != 2) { System.out.println("Usage: CountRowKeys tableName outputPath"); return 1; Job job = new Job(getConf(), this.getClass().getName()); job.setJarByClass(this.getClass()); job.setInputFormatClass(SequenceFileInputFormat.class); SequenceFileInputFormat.addInputPath(job, new Path(ServerConstants.getTablesDir() + "/" + args[0] + "/*/*/data")); job.setMapperClass(MyMapper.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(NullWritable.class); job.setReducerClass(MyReducer.class); TextOutputFormat.setOutputPath(job, new Path(args[1])); job.waitForCompletion(true); return job.isSuccessful() ? 0 : 1; } public static void main(String[] args) throws Exception { int res = ToolRunner.run(CachedConfiguration.getInstance(), new CountRowKeys(), args); if (res != 0) System.exit(res); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.core.client.mock; import java.util.Map.Entry; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; class MockEntry implements Entry<Key, Value> { Key key; Value value; public MockEntry(Key key, Value value) { this.key = key; this.value = value; } @Override public Key getKey() { return key; } @Override public Value getValue() { return value; } @Override public Value setValue(Value value) { Value result = this.value; this.value = value; return result; } @Override public String toString() { return key.toString() + " -> " + value.toString(); } @Override public boolean equals(Object obj) { if (!(obj instanceof MockEntry)) { return false; } MockEntry entry = (MockEntry) obj; return key.equals(entry.key) && value.equals(entry.value); } @Override public int hashCode() { return key.hashCode() * 31 + value.hashCode(); } }
Return empty string instead.
* * * * * *
Replace all tab characters in this file by sequences of white-spaces.
package org.apache.accumulo.examples.wikisearch.ingest; import java.util.LinkedHashMap; import java.util.Map; public class LRUOutputCombiner<Key,Value> extends LinkedHashMap<Key,Value> { private static final long serialVersionUID = 1L; public static abstract class Fold <Value> { public abstract Value fold(Value oldValue, Value newValue); } public static abstract class Output<Key,Value> { public abstract void output(Key key, Value value); } private final int capacity; private final Fold<Value> fold; private final Output<Key,Value> output; private long cacheHits = 0; private long cacheMisses = 0; public LRUOutputCombiner(int capacity, Fold<Value> fold, Output<Key,Value> output) { super(capacity + 1, 1.1f, true); this.capacity = capacity; this.fold = fold; this.output = output; } protected boolean removeEldestEntry(Map.Entry<Key,Value> eldest) { if (size() > capacity) { output.output(eldest.getKey(), eldest.getValue()); return true; } return false; } @Override public Value put(Key key, Value value) { Value val = get(key); if (val != null) { value = fold.fold(val, value); cacheHits++; } else { cacheMisses++; } super.put(key, value); return null; } public void flush() { for (Map.Entry<Key,Value> e : entrySet()) { output.output(e.getKey(), e.getValue()); } clear(); } }
Introduce a new variable instead of reusing the parameter "value".
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.DataFileColumnFamily; TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value(dir.getBytes())); mut.put(DataFileColumnFamily.NAME, new Text(dir + "/00000_0000" + i + ".map"), new Value("10000,1000000".getBytes())); bs.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME); TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(bs);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
Connector c = mockInstance.getConnector("root", new byte[] {}); AccumuloInputFormat.setConnectorInfo(job, user, pass.getBytes(Charset.forName("UTF-8")));
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.
public class MapReduceIT extends SimpleMacIT { Process hash = exec(RowHash.class, "-i", c.getInstance().getInstanceName(), "-z", c.getInstance().getZooKeepers(),
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (count != 1) throw new Exception("Did not see expected # entries " + count); if (count != 1) throw new Exception("Did not see expected # entries " + count);
Remove this call to "exit" or ensure it is really required.
package org.apache.accumulo.test.randomwalk.sequential; 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.
CacheEntry ce = cache.getBlock(block.blockName); assertTrue(ce != null); assertEquals(ce.getBuffer().length, block.buf.length); CacheEntry ce = cache.getBlock(block.blockName); assertTrue(ce != null); assertEquals(ce.getBuffer().length, block.buf.length); assertEquals(cache.getBlock(blocks[i].blockName).getBuffer(), blocks[i].buf); assertEquals(cache.getBlock(block.blockName).getBuffer(), block.buf); assertEquals(cache.getBlock(singleBlocks[i].blockName).getBuffer(), singleBlocks[i].buf); assertEquals(cache.getBlock(multiBlocks[i].blockName).getBuffer(), multiBlocks[i].buf); assertEquals(singleBlocks[i].buf, cache.getBlock(singleBlocks[i].blockName).getBuffer()); assertEquals(multiBlocks[i].buf, cache.getBlock(multiBlocks[i].blockName).getBuffer()); assertEquals(memoryBlocks[i].buf, cache.getBlock(memoryBlocks[i].blockName).getBuffer());
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.
return new ByteArrayInputStream(sb.toString().getBytes());
Remove this unused method parameter "ex".
AccumuloInputFormat.setConnectorInfo(job, args[0], new PasswordToken(args[1])); AccumuloOutputFormat.setConnectorInfo(job, args[0], new PasswordToken(args[1]));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.PasswordToken;
1 duplicated blocks of code must be removed.
import org.apache.accumulo.core.security.CredentialHelper; import org.apache.accumulo.core.security.thrift.Credential; String principal = getPrincipal(implementingClass, conf); String tokenClass = getTokenClass(implementingClass, conf); byte[] token = getToken(implementingClass, conf); return TabletLocator.getInstance(instance, new Credential(principal, tokenClass, ByteBuffer.wrap(token), instance.getInstanceID()), Connector c = getInstance(implementingClass, conf).getConnector( new Credential(getPrincipal(implementingClass, conf), getTokenClass(implementingClass, conf), ByteBuffer.wrap(getToken(implementingClass, conf)), getInstance(implementingClass, conf).getInstanceID())); if (!c.securityOperations().authenticateUser(getPrincipal(implementingClass, conf), CredentialHelper.extractToken(getTokenClass(implementingClass, conf), getToken(implementingClass, conf))))
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig(new Iterable<Entry<String,String>>() { public Iterator<Entry<String,String>> iterator() { return getSystemConfiguration().iterator(); }));
Either log or rethrow this exception.
shellState.getReader().println(line);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public static final int DATA_VERSION = 4; public static final int PREV_DATA_VERSION = 3;
Remove this call to "exit" or ensure it is really required.
if (tokens.length > 1) { throw new ThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.OTHER, "Another compaction with iterators is running"); }
Move this constructor to comply with Java Code Conventions.
package org.apache.accumulo.core.util; import java.util.Collection; public final class StringUtil { public static String join(Collection<String> strings, String sep) { int last = 0; StringBuilder ret = new StringBuilder(); for (String s : strings) { ret.append(s); last = ret.length(); ret.append(sep); } ret.delete(last, ret.length()); return ret.toString(); } }
Return empty string instead.
import org.apache.accumulo.core.security.tokens.UserPassToken; Connector conn = mi.getConnector(new UserPassToken("", "")); Connector conn = mi.getConnector(new UserPassToken("", "")); Connector conn = mi.getConnector(new UserPassToken("", "")); Connector conn = mi.getConnector(new UserPassToken("", "")); Connector conn = mi.getConnector(new UserPassToken("", "")); Connector conn = mi.getConnector(new UserPassToken("", "")); Connector conn = mi.getConnector(new UserPassToken("", ""));
Either log or rethrow this exception.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.core.security.crypto; import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; import org.apache.log4j.Logger; public class DiscardCloseOutputStream extends FilterOutputStream { private static final Logger log = Logger.getLogger(DiscardCloseOutputStream.class); public DiscardCloseOutputStream(OutputStream out) { super(out); } public void close() throws IOException { // Discard log.trace("Discarded close"); } }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.tokens.AccumuloToken; import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper; // There are places where we need information from the token. But we don't want to convert to a thrift object for every call. // So we'll keep both on hand and pass them around. private InstanceTokenWrapper token; * @param token public ConnectorImpl(Instance instance, final AccumuloToken<?,?> token2) throws AccumuloException, AccumuloSecurityException { ArgumentChecker.notNull(instance, token2); this.token = new InstanceTokenWrapper(token2, instance.getInstanceID()); if (!token.getPrincipal().equals("!SYSTEM")) { iface.authenticateUser(Tracer.traceInfo(), token.toThrift(), token.toThrift().token); return new TabletServerBatchReader(instance, token, getTableId(tableName), authorizations, numQueryThreads); return new TabletServerBatchDeleter(instance, token, getTableId(tableName), authorizations, numQueryThreads, new BatchWriterConfig() return new TabletServerBatchDeleter(instance, token, getTableId(tableName), authorizations, numQueryThreads, config); return new BatchWriterImpl(instance, token, getTableId(tableName), new BatchWriterConfig().setMaxMemory(maxMemory) return new BatchWriterImpl(instance, token, getTableId(tableName), config); return new MultiTableBatchWriterImpl(instance, token, new BatchWriterConfig().setMaxMemory(maxMemory) return new MultiTableBatchWriterImpl(instance, token, config); return new ScannerImpl(instance, token, getTableId(tableName), authorizations); return token.getPrincipal(); tableops = new TableOperationsImpl(instance, token); secops = new SecurityOperationsImpl(instance, token); instanceops = new InstanceOperationsImpl(instance, token);
Immediately return this expression instead of assigning it to the temporary variable "ret".
import org.apache.accumulo.examples.wikisearch.ingest.WikipediaMapper;
2 duplicated blocks of code must be removed.
if (source.hasNext()) currentRow = source.peek().getKey().getRow(); if (disabled) throw new IllegalStateException("SingleRowIter no longer valid"); if (disabled) throw new IllegalStateException("SingleRowIter no longer valid"); if (currentRow == null) throw new NoSuchElementException(); if (!hasNext()) throw new NoSuchElementException();
Remove this call to "exit" or ensure it is really required.
if (cl.hasOption(rowOpt.getOpt())) row = new Text(cl.getOptionValue(rowOpt.getOpt())); if (cl.hasOption(maxOpt.getOpt())) max = Integer.parseInt(cl.getOptionValue(maxOpt.getOpt())); if (!found) return;
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.server.security.SystemCredentials; MetadataTableUtil.deleteTable(tableId, refCount != 0, SystemCredentials.get().getAsThrift(), null); AuditedSecurityOperation.getInstance().deleteTable(SystemCredentials.get().getAsThrift(), tableId);
Move this constructor to comply with Java Code Conventions.
t.attachIterator("table", new IteratorSetting(10, "someName", "foo.bar", empty), EnumSet.of(IteratorScope.scan)); t.attachIterator("table", setting, EnumSet.of(IteratorScope.majc)); t.attachIterator("table", setting, EnumSet.of(IteratorScope.scan)); t.attachIterator("table", setting, EnumSet.of(IteratorScope.majc)); t.attachIterator("table", setting, EnumSet.of(IteratorScope.scan)); t.attachIterator("table", setting, EnumSet.of(IteratorScope.minc));
Remove this unused method parameter "table".
Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET))); Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET)); Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET)); m.putDelete(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt()))); m.putDelete(colf, colq, le); m.putDelete(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt()))); m.putDelete(colf, colq);
Either log or rethrow this exception.
import org.apache.accumulo.server.cli.ClientOpts; import com.beust.jcommander.Parameter; static public class Opts extends ClientOpts { @Parameter(names={"-r", "--row"}, required=true, description="find tablets that contain this row") String row = null; @Parameter(names="--tableId", required=true, description="table id") String tableId = null; } public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(FindTablet.class.getName(), args); findContainingTablets(opts); private static void findContainingTablets(Opts opts) throws Exception { Range range = new KeyExtent(new Text(opts.tableId), null, null).toMetadataRange(); Scanner scanner = opts.getConnector().createScanner("createEvents", opts.auths); Text row = new Text(opts.row); if (ke.contains(row)) {
Remove this call to "exit" or ensure it is really required.
package org.apache.accumulo.examples.simple.mapreduce.bulk;
2 duplicated blocks of code must be removed.
import org.apache.accumulo.proxy.thrift.PTimeType; tpc.proxy().tableOperations_create(userpass, testtable, true, PTimeType.MILLIS);
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
shellState.getConnector().securityOperations().changeUserAuthorizations(user, ScanCommand.parseAuthorizations(scanOpts));
1 duplicated blocks of code must be removed.
private boolean scanColumns; private HashSet<ByteSequence> columnFamilies; private HashMap<ByteSequence,HashSet<ByteSequence>> columnsQualifiers; public ColumnQualifierFilter(HashSet<Column> columns) { this.init(columns); } public boolean accept(Key key, Value v) { if (!scanColumns) return true; if (columnFamilies.contains(key.getColumnFamilyData())) return true; HashSet<ByteSequence> cfset = columnsQualifiers.get(key.getColumnQualifierData()); // ensure the columm qualifier goes with a paired column family, // it is possible that a column qualifier could occur with a // column family it was not paired with return cfset != null && cfset.contains(key.getColumnFamilyData()); } public void init(HashSet<Column> columns) { this.columnFamilies = new HashSet<ByteSequence>(); this.columnsQualifiers = new HashMap<ByteSequence,HashSet<ByteSequence>>(); for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) { Column col = iter.next(); if (col.columnQualifier != null) { ArrayByteSequence cq = new ArrayByteSequence(col.columnQualifier); HashSet<ByteSequence> cfset = this.columnsQualifiers.get(cq); if (cfset == null) { cfset = new HashSet<ByteSequence>(); this.columnsQualifiers.put(cq, cfset); cfset.add(new ArrayByteSequence(col.columnFamily)); } else { // this whole column family should pass columnFamilies.add(new ArrayByteSequence(col.columnFamily)); } // only take action when column qualifies are present scanColumns = this.columnsQualifiers.size() > 0; } @Override public void init(Map<String,String> options) { // don't need to do anything }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (!tests.job.isSuccessful()) System.exit(1);
Remove this call to "exit" or ensure it is really required.
import java.nio.ByteBuffer; import org.apache.accumulo.core.security.thrift.Credentials; private Credentials token = new Credentials("", ByteBuffer.wrap("".getBytes()), ""); protected void setToken(Credentials token) { protected Credentials getToken() { return getInstance().getConnector(token.getPrincipal(), token.getToken()); fTest.setToken(new Credentials(opts.user, ByteBuffer.wrap(opts.password.value), opts.instance));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.iterators.user.RegExFilter; Configuration conf = attempt.getConfiguration(); Instance instance = getInstance(conf); String user = getUsername(conf); byte[] password = getPassword(conf); Authorizations authorizations = getAuthorizations(conf); log.debug("Creating scanner for table: " + getTablename(conf)); if (isOfflineScan(conf)) { getTablename(conf)), authorizations); scanner = conn.createScanner(getTablename(conf), authorizations); if (isIsolated(conf)) { if (usesLocalIterators(conf)) { setupMaxVersions(conf, scanner); IteratorSetting is = new IteratorSetting(50, RegExFilter.class); RegExFilter.setRegexs(is, conf.get(ROW_REGEX), conf.get(COLUMN_FAMILY_REGEX), conf.get(COLUMN_QUALIFIER_REGEX), null, false); scanner.addScanIterator(is); setupIterators(conf, scanner); for (Pair<Text,Text> c : getFetchedColumns(conf)) {
Replace all tab characters in this file by sequences of white-spaces.
while (getSource().hasTop() && !getSource().getTopKey().isDeleted() && (negate == accept(getSource().getTopKey(), getSource().getTopValue()))) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
* A simple map reduce job that computes the unique column families and column qualifiers in a table. This example shows one way to run against an offline * table. public static class UMapper extends Mapper<Key,Value,Text,Text> { @Override @Override @Parameter(names = "--output", description = "output directory") @Parameter(names = "--reducers", description = "number of reducers to use", required = true) @Parameter(names = "--offline", description = "run against an offline table") AccumuloInputFormat.setOfflineTableScan(job, true);
Return empty string instead.
import org.apache.accumulo.examples.wikisearch.normalizer.LcNoDiacriticsNormalizer; import org.apache.accumulo.examples.wikisearch.normalizer.Normalizer; import org.apache.accumulo.examples.wikisearch.protobuf.Uid; import org.apache.accumulo.examples.wikisearch.util.TextUtil;
2 duplicated blocks of code must be removed.
private long next = 0; private long maxAllocated = 0; private String nextNamePath; private Random rand; private UniqueNameAllocator() { nextNamePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID() + Constants.ZNEXT_FILE; rand = new Random(); } public synchronized String getNextName() { while (next >= maxAllocated) { final int allocate = 100 + rand.nextInt(100); try { byte[] max = ZooReaderWriter.getInstance().mutate(nextNamePath, null, ZooUtil.PRIVATE, new ZooReaderWriter.Mutator() { public byte[] mutate(byte[] currentValue) throws Exception { long l = Long.parseLong(new String(currentValue), Character.MAX_RADIX); l += allocate; return Long.toString(l, Character.MAX_RADIX).getBytes(); } }); maxAllocated = Long.parseLong(new String(max), Character.MAX_RADIX); next = maxAllocated - allocate; } catch (Exception e) { throw new RuntimeException(e); } return new String(FastFormat.toZeroPaddedString(next++, 7, Character.MAX_RADIX, new byte[0])); } private static UniqueNameAllocator instance = null; public static synchronized UniqueNameAllocator getInstance() { if (instance == null) instance = new UniqueNameAllocator(); return instance; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.cli.BatchWriterOpts; import org.apache.accumulo.core.cli.ScannerOpts; import org.apache.accumulo.server.cli.ClientOpts; import com.beust.jcommander.Parameter; static class Opts extends ClientOpts { @Parameter(names="--readonly", description="read only") boolean readonly = false; @Parameter(names="--tables", description="number of tables to create") int tables = 5; @Parameter(names="--count", description="number of entries to create") int count = 10000; private static void readBack(Opts opts, ScannerOpts scanOpts, Connector conn) throws Exception { Scanner scanner = conn.createScanner(table, opts.auths); scanner.setBatchSize(scanOpts.scanBatchSize); if (!elt.getKey().getRow().toString().equals(expected)) throw new RuntimeException("entry " + elt + " does not match expected " + expected + " in table " + table); Opts opts = new Opts(); ScannerOpts scanOpts = new ScannerOpts(); BatchWriterOpts bwOpts = new BatchWriterOpts(); opts.parseArgs(TestMultiTableIngest.class.getName(), args, scanOpts, bwOpts); connector = opts.getConnector(); for (int i = 0; i < opts.tables; i++) { if (!opts.readonly) { b = connector.createMultiTableBatchWriter(bwOpts.getBatchWriterConfig()); for (int i = 0; i < opts.count; i++) { readBack(opts, scanOpts, connector);
Remove this unused private "appendProp" method.
@Deprecated
Return empty string instead.
import org.apache.accumulo.core.cli.ClientOnRequiredTable; ClientOnRequiredTable opts = new ClientOnRequiredTable(); opts.parseArgs(this.getClass().getName(), args); opts.setAccumuloConfigs(job); Text table = new Text(opts.tableName); rw.write(table, m); // repeat until done
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. */ public class InfoCommand extends AboutCommand {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.util.ArrayList; import java.util.List; import org.apache.accumulo.core.cli.ClientOnRequiredTable; import com.beust.jcommander.Parameter; static class Opts extends ClientOnRequiredTable { @Parameter(names="--partitions", required=true, description="the number of shards to create") int partitions; @Parameter(required=true, description="<file> { <file> ... }") List<String> files = new ArrayList<String>(); Opts opts = new Opts(); opts.parseArgs(Index.class.getName(), args); BatchWriter bw = opts.getConnector().createBatchWriter(opts.tableName, opts.getBatchWriterConfig()); for (String filename : opts.files) { index(opts.partitions, new File(filename), splitRegex, bw);
Remove this call to "exit" or ensure it is really required.
if (!first) sb.append(", "); if (!first) sb.append(", "); if (!first) sb.append(", ");
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.
Collection<Text> splits = getConnector().tableOperations().listSplits("bss"); splits = getConnector().tableOperations().listSplits("bss"); splits = getConnector().tableOperations().listSplits("bss");
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.
import org.apache.accumulo.core.security.thrift.SecurityErrorCode;
1 duplicated blocks of code must be removed.
shellState.getReader().flush(); shellState.getReader().print(String.format("[%s] %s%n", delete ? "DELETED" : "SKIPPED", entryStr));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
checkSplits(REG_TABLE_NAME, NUM_PRE_SPLITS/2, NUM_PRE_SPLITS * 4);
Remove this unused method parameter "ex".
import org.apache.accumulo.core.client.BatchWriterConfig; writer = conn.createBatchWriter(tableName, new BatchWriterConfig().setMaxMemory(9000l).setMaxWriteThreads(1));
Remove this unused method parameter "e".
import org.apache.accumulo.core.util.ByteArraySet; @Parameter(names = {"-C", "--createtable"}, description = "create table before doing anything") @Parameter(names = {"-D", "--deletetable"}, description = "delete table when finished") @Parameter(names = {"-c", "--create"}, description = "create entries before any deletes") @Parameter(names = {"-r", "--read"}, description = "read entries after any creates/deletes") @Parameter(names = {"-d", "--delete"}, description = "delete entries after any creates") public Opts() { super(DEFAULT_TABLE_NAME); // add the authorizations to the user Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.user); ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations()); auths.addAll(opts.auths.getAuthorizations()); if (!auths.isEmpty()) conn.securityOperations().changeUserAuthorizations(opts.user, new Authorizations(auths));
Return empty string instead.
import org.apache.accumulo.core.iterators.user.RowDeletingIterator;
Remove the literal "false" boolean value.
public AccumuloServerException(final String server, final TApplicationException tae) { private void setServer(final String server) {
Move this constructor to comply with Java Code Conventions.
import java.nio.charset.Charset; private static final Charset utf8 = Charset.forName("UTF8"); zoo.putPersistentData(path, "forced down".getBytes(utf8), NodeExistsPolicy.OVERWRITE);
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. */
Replace all tab characters in this file by sequences of white-spaces.
package org.apache.accumulo.server.test.randomwalk; import java.util.Properties; import org.apache.log4j.Logger; /** * Represents a point in graph of RandomFramework */ public abstract class Node { protected final Logger log = Logger.getLogger(this.getClass()); /** * Visits node * @param state Random walk state passed between nodes * @throws Exception */ public abstract void visit(State state, Properties props) throws Exception; @Override public boolean equals(Object o) { return toString().equals(o.toString()); } @Override public int hashCode() { return toString().hashCode(); } }
Return empty string instead.
import org.apache.accumulo.trace.instrument.Span; import org.apache.accumulo.trace.thrift.RemoteSpan; import org.apache.accumulo.trace.thrift.SpanReceiver.Iface; import org.apache.accumulo.trace.thrift.SpanReceiver.Processor;
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator; ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(ski1); cfsi.seek(new Range("r1"), columns, true); assertFalse(cfsi.hasTop());
Use "Integer.toString" instead.
throw new IllegalArgumentException("invalid option " + RADIX_OPTION + ":" + options.get(RADIX_OPTION));
Return empty string instead.
if (cachedHdfsZooInstance == null) cachedHdfsZooInstance = new HdfsZooInstance(); if (instanceId == null) _getInstanceID(); if (conf == null) conf = ServerConfiguration.getSystemConfiguration();
Remove this call to "exit" or ensure it is really required.