Diff
stringlengths
10
2k
Message
stringlengths
28
159
package org.apache.accumulo.core.file.rfile; import java.io.IOException; import java.util.Collection; import java.util.Iterator; import java.util.Map; import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.file.rfile.MultiLevelIndex.IndexEntry; import org.apache.accumulo.core.iterators.IteratorEnvironment; import org.apache.accumulo.core.iterators.SortedKeyValueIterator; class IndexIterator implements SortedKeyValueIterator<Key, Value>{ private Key key; private Iterator<IndexEntry> indexIter; IndexIterator(Iterator<IndexEntry> indexIter){ this.indexIter = indexIter; if(indexIter.hasNext()) key = indexIter.next().getKey(); else key = null; } @Override public SortedKeyValueIterator<Key, Value> deepCopy(IteratorEnvironment env) { throw new UnsupportedOperationException(); } @Override public Key getTopKey() { return key; } @Override public Value getTopValue() { throw new UnsupportedOperationException(); } @Override public boolean hasTop() { return key != null; } @Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { throw new UnsupportedOperationException(); } @Override public void next() throws IOException { if(indexIter.hasNext()) key = indexIter.next().getKey(); else key = null; } @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { throw new UnsupportedOperationException(); } }
Return empty string instead.
import org.apache.accumulo.core.security.Credentials; private final Credentials credentials; public ConnectorImpl(final Instance instance, Credentials cred) throws AccumuloException, AccumuloSecurityException { if (!"org.apache.accumulo.server.security.SystemCredentials$SystemToken".equals(cred.getToken().getClass().getName())) { if (!iface.authenticate(Tracer.traceInfo(), credentials.toThrift(instance)))
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
@Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); TreeSet<Text> splits = new TreeSet<Text>(); for (int i = 0; i < rand.nextInt(10) + 1; i++) splits.add(new Text(String.format("%016x", Math.abs(rand.nextLong())))); try { conn.tableOperations().addSplits(tableName, splits); log.debug("Added " + splits.size() + " splits " + tableName); } catch (TableNotFoundException e) { log.debug("AddSplits " + tableName + " failed, doesnt exist"); } catch (TableOfflineException e) { log.debug("AddSplits " + tableName + " failed, offline"); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
// slow things down a little, otherwise we spam the logs when there are many wake-up events UtilWaitThread.sleep(100); master.assignedTablet(a.tablet);
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.
/** * @deprecated since 1.4 {@link #attachIterator(String, IteratorSetting)} */
1 duplicated blocks of code must be removed.
password = shellState.readMaskedLine("Enter new password for '" + user + "': ", '*'); passwordConfirm = shellState.readMaskedLine("Please confirm new password for '" + user + "': ", '*');
Either log or rethrow this exception.
import org.apache.accumulo.server.security.SystemCredentials; tserver.removeLogs(Tracer.traceInfo(), SystemCredentials.get().getAsThrift(), paths2strings(entry.getValue())); Iterator<LogEntry> iterator = MetadataTableUtil.getLogEntries(SystemCredentials.get().getAsThrift());
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.
@Deprecated
Return empty string instead.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
296 duplicated blocks of code must be removed.
package org.apache.accumulo.core.util; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Version { String package_ = null; int major = 0; int minor = 0; int release = 0; String etcetera = null; public Version(String everything) { parse(everything); } private void parse(String everything) { Pattern pattern = Pattern.compile("(([^-]*)-)?(\\d+)(\\.(\\d+)(\\.(\\d+))?)?(-(.*))?"); Matcher parser = pattern.matcher(everything); if (!parser.matches()) throw new IllegalArgumentException("Unable to parse: " + everything + " as a version"); if (parser.group(1) != null) package_ = parser.group(2); major = Integer.valueOf(parser.group(3)); minor = 0; if (parser.group(5) != null) minor = Integer.valueOf(parser.group(5)); if (parser.group(7) != null) release = Integer.valueOf(parser.group(7)); if (parser.group(9) != null) etcetera = parser.group(9); } public String getPackage() { return package_;} public int getMajorVersion() { return major; } public int getMinorVersion() { return minor; } public int getReleaseVersion() { return release; } public String getEtcetera() { return etcetera; } @Override public String toString() { StringBuilder result = new StringBuilder(); if (package_ != null) { result.append(package_); result.append("-"); } result.append(major); result.append("."); result.append(minor); result.append("."); result.append(release); if (etcetera != null) { result.append("-"); result.append(etcetera); } return result.toString(); } }
Return empty string instead.
import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.file.FileSKVWriter; import org.apache.accumulo.core.file.rfile.RFileOperations; public class CreateRandomRFile { FileSKVWriter mfw; mfw = new RFileOperations().openWriter(file, fs, conf, AccumuloConfiguration.getDefaultConfiguration());
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. */ public static String format(long time) { return format(time, "&nbsp;"); } public static String format(long time, String space) { return format(time, space, "&mdash;"); } public static String format(long time, String space, String zero) { long ms, sec, min, hr, day, yr; ms = sec = min = hr = day = yr = -1; if (time == 0) return zero; ms = time % 1000; time /= 1000; if (time == 0) return String.format("%dms", ms); sec = time % 60; time /= 60; if (time == 0) return String.format("%ds" + space + "%dms", sec, ms); min = time % 60; time /= 60; if (time == 0) return String.format("%dm" + space + "%ds", min, sec); hr = time % 24; time /= 24; if (time == 0) return String.format("%dh" + space + "%dm", hr, min); day = time % 365; time /= 365; if (time == 0) return String.format("%dd" + space + "%dh", day, hr); yr = time; return String.format("%dy" + space + "%dd", yr, day); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.iterators.user.SummingCombiner; t.append(SummingCombiner.FIXED_LEN_ENCODER.encode(s), 0, 8);
Either log or rethrow this exception.
import org.apache.accumulo.server.security.SystemCredentials; update(SystemCredentials.get().getAsThrift(), createDeleteMutation(tableId, path), new KeyExtent(new Text(tableId), null, null)); update(SystemCredentials.get().getAsThrift(), zooLock, m, entry.extent); Connector conn = instance.getConnector(SystemCredentials.get().getPrincipal(), SystemCredentials.get().getToken()); deleteTable(tableId, false, SystemCredentials.get().getAsThrift(), null); update(SystemCredentials.get().getAsThrift(), zooLock, m, extent); update(SystemCredentials.get().getAsThrift(), m, new KeyExtent(new Text("anythingNotMetadata"), null, null)); update(SystemCredentials.get().getAsThrift(), m, new KeyExtent(new Text("anythingNotMetadata"), null, null));
Move this constructor to comply with Java Code Conventions.
import org.apache.accumulo.core.security.tokens.PasswordToken;
Replace all tab characters in this file by sequences of white-spaces.
package org.apache.accumulo.core.client; import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException; /** * Thrown when the table specified already exists, and it was expected that it didn't */ public class TableExistsException extends Exception { /** * Exception to throw if an operation is attempted on a table that already * exists. * */ private static final long serialVersionUID = 1L; /** * @param tableId the internal id of the table that exists * @param tableName the visible name of the table that exists * @param description the specific reason why it failed */ public TableExistsException(String tableId, String tableName, String description) { super("Table" + (tableName != null && !tableName.isEmpty() ? " " + tableName : "") + (tableId != null && !tableId.isEmpty() ? " (Id=" + tableId + ")" : "") + " exists" + (description != null && !description.isEmpty() ? " (" + description + ")" : "")); } /** * @param tableId the internal id of the table that exists * @param tableName the visible name of the table that exists * @param description the specific reason why it failed * @param cause the exception that caused this failure */ public TableExistsException(String tableId, String tableName, String description, Throwable cause) { this(tableId, tableName, description); super.initCause(cause); } /** * @param e constructs an exception from a thrift exception */ public TableExistsException(ThriftTableOperationException e) { this(e.getTableId(), e.getTableName(), e.getDescription(), e); } }
Return empty string instead.
@Deprecated
Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable".
/* * 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 static MasterClientService.Client getConnectionWithRetry(Instance instance) { MasterClientService.Client result = getConnection(instance); public static MasterClientService.Client getConnection(Instance instance) { MasterClientService.Client client = ThriftUtil.getClient(new MasterClientService.Client.Factory(), master, Property.MASTER_CLIENTPORT, public static <T> T execute(Instance instance, ClientExecReturn<T,MasterClientService.Client> exec) throws AccumuloException, AccumuloSecurityException { MasterClientService.Client client = null; public static void execute(Instance instance, ClientExec<MasterClientService.Client> exec) throws AccumuloException, AccumuloSecurityException { MasterClientService.Client client = null;
Immediately return this expression instead of assigning it to the temporary variable "client".
package org.apache.accumulo.core.iterators.aggregation; import java.io.IOException; import org.apache.accumulo.core.data.Value; import org.apache.log4j.Logger; public class LongSummation implements Aggregator { private static final Logger log = Logger.getLogger(LongSummation.class); long sum = 0; public Value aggregate() { return new Value(longToBytes(sum)); } public void collect(Value value) { try { sum += bytesToLong(value.get()); } catch (IOException e) { log.error(LongSummation.class.getSimpleName() + " trying to convert bytes to long, but byte array isn't length 8"); } } public void reset() { sum = 0; } public static long bytesToLong(byte[] b) throws IOException { return bytesToLong(b,0); } public static long bytesToLong(byte[] b, int offset) throws IOException { if (b.length<offset+8) throw new IOException("trying to convert to long, but byte array isn't long enough, wanted "+(offset+8)+" found "+b.length); return (((long)b[offset+0] << 56) + ((long)(b[offset+1] & 255) << 48) + ((long)(b[offset+2] & 255) << 40) + ((long)(b[offset+3] & 255) << 32) + ((long)(b[offset+4] & 255) << 24) + ((b[offset+5] & 255) << 16) + ((b[offset+6] & 255) << 8) + ((b[offset+7] & 255) << 0)); } public static byte[] longToBytes(long l) { byte[] b = new byte[8]; b[0] = (byte)(l >>> 56); b[1] = (byte)(l >>> 48); b[2] = (byte)(l >>> 40); b[3] = (byte)(l >>> 32); b[4] = (byte)(l >>> 24); b[5] = (byte)(l >>> 16); b[6] = (byte)(l >>> 8); b[7] = (byte)(l >>> 0); return b; } }
Return empty string instead.
private static final Logger log = Logger.getLogger(TabletLocationState.class); public TabletLocationState(KeyExtent extent, TServerInstance future, TServerInstance current, TServerInstance last, Collection<Collection<String>> walogs, boolean chopped) { this.extent = extent; this.future = future; this.current = current; this.last = last; if (walogs == null) walogs = Collections.emptyList(); this.walogs = walogs; this.chopped = chopped; if (current != null && future != null) { log.error(extent + " is both assigned and hosted, which should never happen: " + this); } final public KeyExtent extent; final public TServerInstance future; final public TServerInstance current; final public TServerInstance last; final public Collection<Collection<String>> walogs; final public boolean chopped; public String toString() { return extent + "@(" + future + "," + current + "," + last + ")" + (chopped ? " chopped" : ""); } public TServerInstance getServer() { TServerInstance result = null; if (current != null) { result = current; } else if (future != null) { result = future; } else { result = last; return result; } public TabletState getState(Set<TServerInstance> liveServers) { TServerInstance server = getServer(); if (server == null) return TabletState.UNASSIGNED; if (server.equals(current) || server.equals(future)) { if (liveServers.contains(server)) if (server.equals(future)) { return TabletState.ASSIGNED; } else { return TabletState.HOSTED; } else { return TabletState.ASSIGNED_TO_DEAD_SERVER; } // server == last return TabletState.UNASSIGNED; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public interface Authenticator { public Set<Class<? extends AuthenticationToken>> getSupportedTokenTypes();
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
import org.apache.accumulo.core.security.thrift.Credentials; import org.apache.accumulo.core.security.SecurityUtil; private Credentials credentials; public void init(FileSystem fs, Instance instance, Credentials credentials, boolean noTrash) throws IOException { Scanner scanner = instance.getConnector(credentials.getPrincipal(), credentials.getToken()).createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS); scanner = new IsolatedScanner(instance.getConnector(credentials.getPrincipal(), credentials.getToken()).createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS)); c = instance.getConnector(SecurityConstants.SYSTEM_PRINCIPAL, SecurityConstants.getSystemToken()); public GCStatus getStatus(TInfo info, Credentials credentials) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.core.security.Authorizations; VisibilityFilter visFilter = new VisibilityFilter(colFilter, Authorizations.EMPTY, new byte[0]);
Remove this unused method parameter "range".
Accumulo.enableTracing(local.getHostName(), "tserver");
Rename this package name to match the regular expression '^[a-z]+(\.[a-z][a-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.wikisearch.ingest;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
masterStatus.addSortableColumn("Entries<br />Read", new NumberType<Long>(), "The total number of Key/Value pairs read on the server side. Not all may be returned because of filtering."); masterStatus.addSortableColumn("Entries<br />Returned", new NumberType<Long>(), "The total number of Key/Value pairs returned as a result of scans."); row.add(Math.round(Monitor.getTotalScanRate()));
Use isEmpty() to check whether the collection is empty or not.
* * * * * * * * * * *
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 void undo(long tid, Master environment) throws Exception {}
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
private ServerConfiguration configuration = null; public void init(ServerConfiguration configuration) { this.configuration = configuration; } return configuration.getConfiguration().getCount(Property.TSERV_LOGGER_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. */ @SuppressWarnings("all") public enum TablePermission implements org.apache.thrift.TEnum {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
@Override private MiniAccumuloConfig config; argList.addAll(Arrays.asList(javaBin, "-cp", classpath, "-Xmx128m", "-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", className)); public MiniAccumuloCluster(File dir, String rootPassword) throws IOException { this(new MiniAccumuloConfig(dir, rootPassword)); } /** * @param config * initial configuration * @throws IOException */ public MiniAccumuloCluster(MiniAccumuloConfig config) throws IOException { @Override
Return empty string instead.
if (parts[1].isEmpty()) return new InetSocketAddress(parts[0], service.getDefaultPort()); if (o instanceof ServerServices) return toString().equals(((ServerServices) o).toString());
Remove this call to "exit" or ensure it is really required.
public void update(KeyExtent ke, TabletState state, boolean chopped, boolean hasWALs) { if (chopped && !hasWALs) if (!tls.walogs.isEmpty()) { return false; } verify.update(tls.extent, tls.getState(master.onlineTabletServers()), tls.chopped, !tls.walogs.isEmpty());
The Cyclomatic Complexity of this method "update" is 13 which is greater than 10 authorized.
if (k.getRow().toString().endsWith("0")) return true; if (k.getColumnFamily().toString().equals("a")) return false;
Remove this call to "exit" or ensure it is really required.
String package_ = null; int major = 0; int minor = 0; int release = 0; String etcetera = null; public Version(String everything) { parse(everything); } private void parse(String everything) { Pattern pattern = Pattern.compile("(([^-]*)-)?(\\d+)(\\.(\\d+)(\\.(\\d+))?)?(-(.*))?"); Matcher parser = pattern.matcher(everything); if (!parser.matches()) throw new IllegalArgumentException("Unable to parse: " + everything + " as a version"); if (parser.group(1) != null) package_ = parser.group(2); major = Integer.valueOf(parser.group(3)); minor = 0; if (parser.group(5) != null) minor = Integer.valueOf(parser.group(5)); if (parser.group(7) != null) release = Integer.valueOf(parser.group(7)); if (parser.group(9) != null) etcetera = parser.group(9); } public String getPackage() { return package_; } public int getMajorVersion() { return major; } public int getMinorVersion() { return minor; } public int getReleaseVersion() { return release; } public String getEtcetera() { return etcetera; } @Override public String toString() { StringBuilder result = new StringBuilder(); if (package_ != null) { result.append(package_); result.append("-"); result.append(major); result.append("."); result.append(minor); result.append("."); result.append(release); if (etcetera != null) { result.append("-"); result.append(etcetera); return result.toString(); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.server.ServerOpts; ServerOpts opts = new ServerOpts(); opts.parseArgs("monitor", args); String hostname = opts.getAddress();
Remove this unused method parameter "threadName".
package org.apache.accumulo.examples.simple.mapreduce;
Rename "table" which hides the field declared at line 107.
while (locations != null && locations.getLocations().isEmpty() && locations.getLocationless().isEmpty()) {
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.accumulo.core.cli; import org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat; import org.apache.accumulo.core.client.mapreduce.AccumuloOutputFormat; import org.apache.hadoop.mapreduce.Job; import com.beust.jcommander.Parameter; public class ClientOnRequiredTable extends ClientOpts { @Parameter(names={"-t", "--table"}, required=true, description="table to use") public String tableName = null; @Override public void setAccumuloConfigs(Job job) { super.setAccumuloConfigs(job); AccumuloInputFormat.setInputInfo(job.getConfiguration(), user, getPassword(), tableName, auths); AccumuloOutputFormat.setOutputInfo(job.getConfiguration(), user, getPassword(), true, tableName); } }
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.
private long count; public CountingIterator deepCopy(IteratorEnvironment env) { return new CountingIterator(this, env); } private CountingIterator(CountingIterator other, IteratorEnvironment env) { setSource(other.getSource().deepCopy(env)); count = 0; } public CountingIterator(SortedKeyValueIterator<Key,Value> source) { this.setSource(source); count = 0; } @Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) { throw new UnsupportedOperationException(); } @Override public void next() throws IOException { super.next(); count++; } public long getCount() { return count; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
// get a connection to a random tablet server, do not prefer cached connections because // this is running on the master and there are lots of connections to tablet servers // serving the !METADATA tablets Pair<String,Iface> pair = ServerClient.getConnection(master.getInstance(), false);
Do not forget to remove this deprecated code someday.
return TabletLocator.getLocator(instance, new Text(Tables.getTableId(instance, tableName)));
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.util.Map.Entry; Properties nodeProps = getProps(nextNodeId); nextNode.visit(state, nodeProps); log.debug("Properties for node: " + nextNodeId); for (Entry<Object,Object> entry : nodeProps.entrySet()) { log.debug(" " + entry.getKey() + ": " + entry.getValue()); }
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.
public GCStatus getStatus(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials) throws org.apache.accumulo.core.security.thrift.ThriftSecurityException, org.apache.thrift.TException; public GCStatus getStatus(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials) throws org.apache.accumulo.core.security.thrift.ThriftSecurityException, org.apache.thrift.TException public GCStatus recv_getStatus() throws org.apache.accumulo.core.security.thrift.ThriftSecurityException, org.apache.thrift.TException public GCStatus getResult() throws org.apache.accumulo.core.security.thrift.ThriftSecurityException, org.apache.thrift.TException { } catch (org.apache.accumulo.core.security.thrift.ThriftSecurityException sec) { public org.apache.accumulo.core.security.thrift.ThriftSecurityException sec; // required org.apache.accumulo.core.security.thrift.ThriftSecurityException sec) this.sec = new org.apache.accumulo.core.security.thrift.ThriftSecurityException(other.sec); public org.apache.accumulo.core.security.thrift.ThriftSecurityException getSec() { public getStatus_result setSec(org.apache.accumulo.core.security.thrift.ThriftSecurityException sec) { setSec((org.apache.accumulo.core.security.thrift.ThriftSecurityException)value); struct.sec = new org.apache.accumulo.core.security.thrift.ThriftSecurityException(); struct.sec = new org.apache.accumulo.core.security.thrift.ThriftSecurityException();
1 duplicated blocks of code must be removed.
public MultiTableBatchWriterImpl(Instance instance, AuthInfo credentials, long maxMemory, long maxLatency, int maxWriteThreads) {
Do not forget to remove this deprecated code someday.
switch (ae.getSecurityErrorCode()) { switch (ae.getSecurityErrorCode()) { switch (ae.getSecurityErrorCode()) {
Do not forget to remove this deprecated code someday.
boolean ambiguousAuths = WalkingSecurity.get(state).ambiguousAuthorizations(); if (!auths.contains(k.getColumnVisibilityData()) && !ambiguousAuths) if (seen != 0 && !ambiguousAuths) if (ae.getErrorCode().equals(SecurityErrorCode.BAD_AUTHORIZATIONS)) { if (ambiguousAuths) return; else throw new AccumuloException("Mismatched authorizations! ", ae); } if (re.getCause() instanceof AccumuloSecurityException && ((AccumuloSecurityException) re.getCause()).getErrorCode().equals(SecurityErrorCode.BAD_AUTHORIZATIONS)) { if (ambiguousAuths) return; else throw new AccumuloException("Mismatched authorizations! ", re.getCause()); }
Define and throw a dedicated exception instead of using a generic one.
scans.add(String.format("%21s |%21s |%9s |%9s |%7s |%6s |%8s |%8s |%10s |%20s |%10s |%10s | %s", tserver, as.getClient(), as.getTable(), as.getColumns(), as.getAuthorizations(), (as.getType() == ScanType.SINGLE ? as.getExtent() : "N/A"), as.getSsiList(), as.getSsio())); final String header = String.format(" %-21s| %-21s| %-9s| %-9s| %-7s| %-6s| %-8s| %-8s| %-10s| %-20s| %-10s| %-10s | %s", "TABLET SERVER", "CLIENT", "AGE", "LAST", "STATE", "TYPE", "USER", "TABLE", "COLUMNS", "AUTHORIZATIONS", "TABLET", "ITERATORS", "ITERATOR OPTIONS");
Replace all tab characters in this file by sequences of white-spaces.
if (s.parentId == Span.ROOT_SPAN_ID) parentString = ""; if (timeMutation != null) writer.addMutation(timeMutation);
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 PrintTable { public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (args.length != 3) { System.out.println("Usage : PrintTable <table> <user> <password>"); return; } Connector connector = HdfsZooInstance.getInstance().getConnector(args[1], args[2].getBytes()); Authorizations auths = connector.securityOperations().getUserAuthorizations(args[1]); Scanner scanner = connector.createScanner(args[0], auths); for (Entry<Key,Value> entry : scanner) System.out.println(DefaultFormatter.formatEntry(entry, true)); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public static void setInputInfo(JobContext job, String user, byte[] passwd, String table, Authorizations auths) { 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); }
Do not forget to remove this deprecated code someday.
synchronized public static SiteConfiguration getInstance(AccumuloConfiguration parent) { synchronized private static Configuration getXmlConfig() {
Reorder the modifiers to comply with the Java Language Specification.
public ThriftMetrics(String serverName, String threadName) { super(); reset(); try { OBJECT_NAME = new ObjectName("accumulo.server.metrics:service=" + serverName + ",name=ThriftMetricsMBean,instance=" + threadName); } catch (Exception e) { log.error("Exception setting MBean object name", e); } } @Override protected ObjectName getObjectName() { return OBJECT_NAME; } @Override protected String getMetricsPrefix() { return METRICS_PREFIX; } public void reset() { createMetric(idle); createMetric(execute); } public long getExecutionAvgTime() { return this.getMetricAvg(execute); } public long getExecutionCount() { return this.getMetricCount(execute); } public long getExecutionMaxTime() { return this.getMetricMax(execute); } public long getExecutionMinTime() { return this.getMetricMin(execute); } public long getIdleAvgTime() { return this.getMetricAvg(idle); } public long getIdleCount() { return this.getMetricCount(idle); } public long getIdleMaxTime() { return this.getMetricMax(idle); } public long getIdleMinTime() { return this.getMetricMin(idle); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
package org.apache.accumulo.server.util; import java.util.HashMap; /** * A HashMap that returns a default value if the key is not stored in the map. * * A zero-argument constructor of the default object's class is used, otherwise the default object is used. */ public class DefaultMap<K, V> extends HashMap<K, V> { private static final long serialVersionUID = 1L; V dfault; public DefaultMap(V dfault) { this.dfault = dfault; } @SuppressWarnings("unchecked") @Override public V get(Object key) { V result = super.get(key); if (result == null) { try { super.put((K)key, result = construct()); } catch (Exception ex) { throw new RuntimeException(ex); } } return result; } @SuppressWarnings("unchecked") private V construct() { try { return (V)dfault.getClass().newInstance(); } catch (Exception ex) { return dfault; } } }
Return empty string instead.
* @param cfg * fully specified scan-time iterator, including all options for the iterator. Any changes to the iterator setting after this call are not propagated * to the stored iterator. * Remove an iterator from the list of iterators * * @param iteratorName * nickname used for the iterator */ public void removeScanIterator(String iteratorName); /**
Define and throw a dedicated exception instead of using a generic one.
prop.setProperty("useMockInstance", "true"); prop.put("tokenClass", PasswordToken.class.getName());
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import org.apache.accumulo.server.zookeeper.IZooReaderWriter; IZooReaderWriter zoo = ZooReaderWriter.getInstance();
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/* * 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.wikisearch.logic; import org.apache.accumulo.wikisearch.ingest.WikipediaMapper; import org.apache.accumulo.wikisearch.iterator.BooleanLogicIterator; import org.apache.accumulo.wikisearch.iterator.EvaluatingIterator; import org.apache.accumulo.wikisearch.iterator.OptimizedQueryIterator; import org.apache.accumulo.wikisearch.iterator.ReadAheadIterator; import org.apache.accumulo.wikisearch.normalizer.LcNoDiacriticsNormalizer; import org.apache.accumulo.wikisearch.normalizer.Normalizer; import org.apache.accumulo.wikisearch.parser.EventFields; import org.apache.accumulo.wikisearch.parser.EventFields.FieldValue; import org.apache.accumulo.wikisearch.parser.FieldIndexQueryReWriter; import org.apache.accumulo.wikisearch.parser.JexlOperatorConstants; import org.apache.accumulo.wikisearch.parser.QueryParser; import org.apache.accumulo.wikisearch.parser.QueryParser.QueryTerm; import org.apache.accumulo.wikisearch.parser.RangeCalculator; import org.apache.accumulo.wikisearch.sample.Document; import org.apache.accumulo.wikisearch.sample.Field; import org.apache.accumulo.wikisearch.sample.Results;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
/** * This class remains here for backwards compatibility. * @deprecated since 1.4 * @see org.apache.accumulo.core.iterators.user.RowDeletingIterator public class RowDeletingIterator extends org.apache.accumulo.core.iterators.user.RowDeletingIterator {
Remove the literal "false" boolean value.
private InstanceOperations instanceOps; private Iterator<String> tsIter; private Iterator<String> scansIter; private void readNext() { List<String> scans = new ArrayList<String>(); while (tsIter.hasNext()) { String tserver = tsIter.next(); try { List<ActiveScan> asl = instanceOps.getActiveScans(tserver); for (ActiveScan as : asl) scans.add(String.format("%21s |%21s |%9s |%9s |%7s |%6s |%8s |%8s |%10s |%10s |%10s | %s", tserver, as.getClient(), Duration.format(as.getAge(), "", "-"), Duration.format(as.getLastContactTime(), "", "-"), as.getState(), as.getType(), as.getUser(), as.getTable(), as.getColumns(), (as.getType() == ScanType.SINGLE ? as.getExtent() : "N/A"), as.getSsiList(), as.getSsio())); } catch (Exception e) { scans.add(tserver + " ERROR " + e.getMessage()); } if (scans.size() > 0) break; scansIter = scans.iterator(); } ActiveScanIterator(List<String> tservers, InstanceOperations instanceOps) { this.instanceOps = instanceOps; this.tsIter = tservers.iterator(); String header = String.format(" %-21s| %-21s| %-9s| %-9s| %-7s| %-6s| %-8s| %-8s| %-10s| %-10s| %-10s | %s", "TABLET SERVER", "CLIENT", "AGE", "LAST", "STATE", "TYPE", "USER", "TABLE", "COLUMNS", "TABLET", "ITERATORS", "ITERATOR OPTIONS"); scansIter = Collections.singletonList(header).iterator(); } @Override public boolean hasNext() { return scansIter.hasNext(); } @Override public String next() { String next = scansIter.next(); if (!scansIter.hasNext()) readNext(); return next; } @Override public void remove() { throw new UnsupportedOperationException(); }
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.
AccumuloInputFormat.setZooKeeperInstance(job.getConfiguration(), args[0], args[1]); AccumuloInputFormat.setInputInfo(job.getConfiguration(), args[2], args[3].getBytes(), args[4], new Authorizations()); AccumuloInputFormat.fetchColumns(job.getConfiguration(), columnsToFetch);
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.cli.BatchWriterOpts; BatchWriterOpts bwOpts = new BatchWriterOpts(); opts.parseArgs(RandomBatchWriter.class.getName(), args, bwOpts); BatchWriter bw = connector.createBatchWriter(opts.tableName, bwOpts.getBatchWriterConfig());
Remove this unused method parameter "opts".
package org.apache.accumulo.examples.simple.client;
2 duplicated blocks of code must be removed.
import org.apache.accumulo.core.client.impl.MasterClient; import org.apache.accumulo.core.master.thrift.MasterClientService.Client; import org.apache.accumulo.core.security.thrift.ThriftSecurityException; import org.apache.accumulo.core.util.ThriftUtil; import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; @Override public String getSecurityTokenClass() throws AccumuloException { Client client = null; try { client = MasterClient.getConnection(this); return client.getSecurityTokenClass(); } catch (TTransportException e) { throw new AccumuloException(e); } catch (ThriftSecurityException e) { throw new AccumuloException(e); } catch (TException e) { throw new AccumuloException(e); } finally { if (client != null) { ThriftUtil.returnClient(client); } } }
Remove this call to "exit" or ensure it is really required.
import org.apache.accumulo.server.fs.VolumeManager.FileType; Path path = VolumeManagerImpl.get().getFullPath(FileType.TABLE, pathToRemove);
Remove this unused private "FileType" constructor.
import org.apache.accumulo.core.util.shell.Token;
Replace all tab characters in this file by sequences of white-spaces.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ private NoLabelFilter ref = new NoLabelFilter(); public NoLabelIterator deepCopy(IteratorEnvironment env) { return new NoLabelIterator(this, env); } private NoLabelIterator(NoLabelIterator other, IteratorEnvironment env) { setSource(other.getSource().deepCopy(env)); ref = other.ref; } public NoLabelIterator() {} private boolean matches(Key key, Value value) { return ref.accept(key, value); } @Override protected void consume() throws IOException { while (getSource().hasTop() && !matches(getSource().getTopKey(), getSource().getTopValue())) { getSource().next(); } } @Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); ref.init(options); } @Override public IteratorOptions describeOptions() { return ref.describeOptions(); } @Override public boolean validateOptions(Map<String,String> options) { return ref.validateOptions(options); }
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.
/** * @return the time this scan has been idle in the tablet server * @return */ public long getIdleTime() { return idle; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
MiniAccumuloConfig config = new MiniAccumuloConfig(folder.getRoot(), "superSecret").setJDWPEnabled(true);
Define a constant instead of duplicating this literal "superSecret" 3 times.
* 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. */ @Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); TreeSet<Text> splits = new TreeSet<Text>(); for (int i = 0; i < rand.nextInt(10) + 1; i++) splits.add(new Text(String.format("%016x", Math.abs(rand.nextLong())))); try { conn.tableOperations().addSplits(tableName, splits); log.debug("Added " + splits.size() + " splits " + tableName); } catch (TableNotFoundException e) { log.debug("AddSplits " + tableName + " failed, doesnt exist"); } catch (TableOfflineException e) { log.debug("AddSplits " + tableName + " failed, offline"); } }
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 class ShellCommandException extends Exception { private static final long serialVersionUID = 1L; public enum ErrorCode { UNKNOWN_ERROR("Unknown error"), UNSUPPORTED_LANGUAGE("Programming language used is not supported"), UNRECOGNIZED_COMMAND("Command is not supported"), INITIALIZATION_FAILURE("Command could not be initialized"), XML_PARSING_ERROR("Failed to parse the XML file"); private String description; private ErrorCode(String description) { this.description = description; } public String getDescription() { return this.description; } public String toString() { return getDescription(); } } private ErrorCode code; private String command; public ShellCommandException(ErrorCode code) { this(code, null); } public ShellCommandException(ErrorCode code, String command) { this.code = code; this.command = command; } public String getMessage() { return code + (command != null ? " (" + command + ")" : ""); }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
public static final String AUDITLOG = "Audit";
Remove this unused method parameter "range".
if (iid.equals("instances")) continue;
Remove this call to "exit" or ensure it is really required.
* <li>{@link AccumuloOutputFormat#setConnectorInfo(JobConf, String, AuthenticationToken)} * @throws AccumuloSecurityException * {@link CredentialHelper#asBase64String(org.apache.accumulo.core.security.thrift.TCredentials)}. * the path to a file in the configured file system, containing the serialized, base-64 encoded {@link AuthenticationToken} with the user's * authentication * @see #setConnectorInfo(JobConf, String, AuthenticationToken) * @see #setConnectorInfo(JobConf, String, AuthenticationToken)
Remove the redundant '!unknownSymbol!' thrown exception declaration(s).
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.TreeMap; private TreeMap<Key,Value> getBuffer(Text tablename) { if (buffer == null) { private Text getLargestTablename() { for (Entry<Text,Long> e : bufferSizes.entrySet()) { if (e.getValue() > max) { private void flushLargestTable() throws IOException { if (tablename == null) while (size > 0) for (ColumnUpdate update : mutation.getUpdates()) { Key k = new Key(mutation.getRow(), update.getColumnFamily(), update.getColumnQualifier(), update.getColumnVisibility(), update.getTimestamp(), update.isDeleted());
Remove this unused private "match" method.
private ThreadFactory dtf = Executors.defaultThreadFactory(); private int threadNum = 1; private String name; public NamingThreadFactory(String name) { this.name = name; } public Thread newThread(Runnable r) { Thread thread = dtf.newThread(r); thread.setName(name + " " + threadNum++); return thread; }
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
if (log.isTraceEnabled()) log.trace("Processing key/value pair: " + DefaultFormatter.formatEntry(entry, true));
Remove this call to "exit" or ensure it is really required.
Connector conn = mi.getConnector("", ""); Connector conn = mi.getConnector("", ""); Connector conn = mi.getConnector("", ""); Connector conn = mi.getConnector("", ""); Connector conn = mi.getConnector("", ""); Connector conn = mi.getConnector("", ""); Connector conn = mi.getConnector("", "");
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.
package org.apache.accumulo.core.iterators; import java.io.IOException; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; public interface IteratorEnvironment { SortedKeyValueIterator<Key, Value> reserveMapFileReader(String mapFileName) throws IOException; AccumuloConfiguration getConfig(); IteratorScope getIteratorScope(); boolean isFullMajorCompaction(); void registerSideChannel(SortedKeyValueIterator<Key, Value> iter); }
Return empty string instead.
* This iterator will *ignore* any columnFamilies passed to {@link #seek(Range, Collection, boolean)} as it performs intersections over terms. Extending classes * should override the {@link TermSource#seekColfams} in their implementation's {@link #init(SortedKeyValueIterator, Map, IteratorEnvironment)} method. public static class TermSource { this.seekColfams = Collections.<ByteSequence> singletonList(new ArrayByteSequence(term.getBytes(), 0, term.getLength()));
Return empty string instead.
package org.apache.accumulo.core.util; import org.apache.accumulo.core.util.Version; import junit.framework.TestCase; public class TestVersion extends TestCase { Version make(String version) { return new Version(version); } public void testOne() { Version v; v = make("abc-1.2.3-ugly"); assertTrue(v != null); assertTrue(v.getPackage().equals("abc")); assertTrue(v.getMajorVersion() == 1); assertTrue(v.getMinorVersion() == 2); assertTrue(v.getReleaseVersion() == 3); assertTrue(v.getEtcetera().equals("ugly")); v = make("3.2.1"); assertTrue(v.getPackage() == null); assertTrue(v.getMajorVersion() == 3); assertTrue(v.getMinorVersion() == 2); assertTrue(v.getReleaseVersion() == 1); assertTrue(v.getEtcetera() == null); v = make("55"); assertTrue(v.getPackage() == null); assertTrue(v.getMajorVersion() == 55); assertTrue(v.getMinorVersion() == 0); assertTrue(v.getReleaseVersion() == 0); assertTrue(v.getEtcetera() == null); v = make("7.1-beta"); assertTrue(v.getPackage() == null); assertTrue(v.getMajorVersion() == 7); assertTrue(v.getMinorVersion() == 1); assertTrue(v.getReleaseVersion() == 0); assertTrue(v.getEtcetera().equals("beta")); try { make("beta"); fail("Should have thrown an error"); } catch (IllegalArgumentException t) { } } }
Return empty string instead.
package org.apache.accumulo.test.functional;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
* * * * * * * *
Replace all tab characters in this file by sequences of white-spaces.
setSource(other.getSource().deepCopy(env)); getSource().next(); if (getSource().hasTop()) { Key k = getSource().getTopKey(); topValue = getSource().getTopValue(); getSource().next(); getSource().seek(range, EMPTY_COL_FAMS, false); getSource().seek(range, columnFamilies, inclusive); if (getSource().hasTop()) { log.debug("seek, source has top: " + getSource().getTopKey()); Key k = getSource().getTopKey(); topValue = getSource().getTopValue(); getSource().next(); getSource().seek(range, columnFamilies, inclusive); getSource().seek(fakeRange, EMPTY_COL_FAMS, false); if (getSource().hasTop()) { return getSource().getTopKey().getRow(); getSource().seek(new Range(), EMPTY_COL_FAMS, false); if (getSource().hasTop()) { return getSource().getTopKey().getRow(); getSource().seek(range, EMPTY_COL_FAMS, false); if (getSource().hasTop()) { log.debug("jump, source has top: " + getSource().getTopKey()); Key k = getSource().getTopKey(); topValue = getSource().getTopValue(); getSource().next(); getSource().seek(range, EMPTY_COL_FAMS, false);
Replace all tab characters in this file by sequences of white-spaces.
import org.apache.accumulo.core.iterators.system.StatsIterator; private AtomicLong seekCount = new AtomicLong(0); // a count of the amount of data read by the iterators private AtomicLong scannedCount = new AtomicLong(0); private Rate scannedRate = new Rate(0.2); private StatsIterator statsIterator; statsIterator = new StatsIterator(multiIter, seekCount, scannedCount); DeletingIterator delIter = new DeletingIterator(statsIterator, false); if (statsIterator != null) { statsIterator.report(); } public long getNumSeeks() { return seekCount.get(); } public double scanRate() { return scannedRate.rate(); } scannedRate.update(now, scannedCount.get());
Use isEmpty() to check whether the collection is empty or not.
package org.apache.accumulo.test.continuous;
Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison.
import org.apache.accumulo.core.security.thrift.TCredentials; import org.apache.accumulo.core.security.tokens.AuthenticationToken; public void initializeSecurity(TCredentials credentials, String principal, byte[] token) throws AccumuloSecurityException, ThriftSecurityException; public boolean authenticateUser(String principal, AuthenticationToken token) throws AccumuloSecurityException; public void createUser(String principal, AuthenticationToken token) throws AccumuloSecurityException; public void changePassword(String principal, AuthenticationToken token) throws AccumuloSecurityException;
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
import java.io.UnsupportedEncodingException; import org.apache.accumulo.core.util.shell.Shell; try { createTokens(); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e.getMessage()); } private void createTokens() throws BadArgumentException, UnsupportedEncodingException { byte[] token = new byte[input.length()]; int tokenLength = 0; byte[] inputBytes = input.getBytes(); token[tokenLength++] = inputBytes[i]; if (!Character.isValidCodePoint(0xff & b)) token[tokenLength++] = b; tokens.add(new String(token, 0, tokenLength, Shell.CHARSET)); tokenLength = 0; token[tokenLength++] = inputBytes[i]; if (tokenLength > 0) { tokens.add(new String(token, 0, tokenLength, Shell.CHARSET)); tokenLength = 0; } else if (ch == ' ' && tokenLength > 0) { tokens.add(new String(token, 0, tokenLength, Shell.CHARSET)); tokenLength = 0; token[tokenLength++] = inputBytes[i]; if (tokenLength > 0) tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
Either log or rethrow this exception.
* @return The number of the partition for a given article.
1 duplicated blocks of code must be removed.
private static volatile AccumuloReloadingVFSClassLoader loader = null; private static ContextManager contextManager; // Set up the 2nd tier class loader // Get the default context classpaths from the configuration loader = new AccumuloReloadingVFSClassLoader(defaultClassPath.toArray(new FileObject[defaultClassPath.size()]), vfs, parent); if (cl instanceof URLClassLoader) { System.out.println("\t" + u.toExternalForm()); } else if (cl instanceof AccumuloReloadingVFSClassLoader) { System.out.println("URL classpath items are: \n"); URLClassLoader ucl = (URLClassLoader) cl.getParent(); for (URL u : ucl.getURLs()) { System.out.println("\t" + u.toExternalForm()); } public static synchronized ContextManager getContextManager() throws IOException { // TODO is there problem with using this lck? if (contextManager == null) { contextManager = new ContextManager(vfs, getClassLoader()); } return contextManager; }
Complete the task associated to this TODO comment.