HBASE-12062 Fix usage of Collections.toArray

This commit is contained in:
Elliott Clark 2014-09-22 21:44:01 -07:00
parent 791a03b40f
commit 2635791027
30 changed files with 57 additions and 91 deletions

View File

@ -235,7 +235,7 @@ public class ServerLoad {
for (Coprocessor coprocessor : obtainServerLoadPB().getCoprocessorsList()) { for (Coprocessor coprocessor : obtainServerLoadPB().getCoprocessorsList()) {
coprocessSet.add(coprocessor.getName()); coprocessSet.add(coprocessor.getName());
} }
return coprocessSet.toArray(new String[0]); return coprocessSet.toArray(new String[coprocessSet.size()]);
} }
/** /**

View File

@ -35,9 +35,7 @@ public class Authorizations {
private List<String> labels; private List<String> labels;
public Authorizations(String... labels) { public Authorizations(String... labels) {
this.labels = new ArrayList<String>(labels.length); this.labels = new ArrayList<String>(labels.length);
for (String label : labels) { Collections.addAll(this.labels, labels);
this.labels.add(label);
}
} }
public Authorizations(List<String> labels) { public Authorizations(List<String> labels) {

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.hbase;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -228,9 +229,7 @@ public class TestKeyValue extends TestCase {
new KeyValue(Bytes.toBytes("a,a,0"), fam, qf, 0, nb), new KeyValue(Bytes.toBytes("a,a,0"), fam, qf, 0, nb),
}; };
// Add to set with bad comparator // Add to set with bad comparator
for (int i = 0; i < keys.length; i++) { Collections.addAll(set, keys);
set.add(keys[i]);
}
// This will output the keys incorrectly. // This will output the keys incorrectly.
boolean assertion = false; boolean assertion = false;
int count = 0; int count = 0;
@ -245,9 +244,7 @@ public class TestKeyValue extends TestCase {
assertTrue(assertion); assertTrue(assertion);
// Make set with good comparator // Make set with good comparator
set = new TreeSet<KeyValue>(new KeyValue.MetaComparator()); set = new TreeSet<KeyValue>(new KeyValue.MetaComparator());
for (int i = 0; i < keys.length; i++) { Collections.addAll(set, keys);
set.add(keys[i]);
}
count = 0; count = 0;
for (KeyValue k: set) { for (KeyValue k: set) {
assertTrue(count++ == k.getTimestamp()); assertTrue(count++ == k.getTimestamp());

View File

@ -119,7 +119,7 @@ public class TestConcatenatedLists {
assertEquals((last == -1), c.isEmpty()); assertEquals((last == -1), c.isEmpty());
assertEquals(last + 1, c.size()); assertEquals(last + 1, c.size());
assertTrue(c.containsAll(c)); assertTrue(c.containsAll(c));
Long[] array = c.toArray(new Long[0]); Long[] array = c.toArray(new Long[c.size()]);
List<Long> all = new ArrayList<Long>(); List<Long> all = new ArrayList<Long>();
Iterator<Long> iter = c.iterator(); Iterator<Long> iter = c.iterator();
for (Long i = 0L; i <= last; ++i) { for (Long i = 0L; i <= last; ++i) {

View File

@ -124,9 +124,7 @@ public class IndexBuilder {
conf.set("index.tablename", tableName); conf.set("index.tablename", tableName);
conf.set("index.familyname", columnFamily); conf.set("index.familyname", columnFamily);
String[] fields = new String[args.length - 2]; String[] fields = new String[args.length - 2];
for(int i = 0; i < fields.length; i++) { System.arraycopy(args, 2, fields, 0, fields.length);
fields[i] = args[i + 2];
}
conf.setStrings("index.fields", fields); conf.setStrings("index.fields", fields);
Job job = new Job(conf, tableName); Job job = new Job(conf, tableName);
job.setJarByClass(IndexBuilder.class); job.setJarByClass(IndexBuilder.class);

View File

@ -127,7 +127,7 @@ public class RollingBatchRestartRsAction extends BatchRestartRsAction {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
serverNames.add(ServerName.valueOf(i + ".example.org", i, i)); serverNames.add(ServerName.valueOf(i + ".example.org", i, i));
} }
return serverNames.toArray(new ServerName [] {}); return serverNames.toArray(new ServerName[serverNames.size()]);
} }
@Override @Override

View File

@ -401,8 +401,7 @@ public class IntegrationTestBigLinkedList extends IntegrationTestBase {
private static <T> void circularLeftShift(T[] first) { private static <T> void circularLeftShift(T[] first) {
T ez = first[0]; T ez = first[0];
for (int i = 0; i < first.length - 1; i++) System.arraycopy(first, 1, first, 0, first.length - 1);
first[i] = first[i + 1];
first[first.length - 1] = ez; first[first.length - 1] = ez;
} }

View File

@ -413,9 +413,7 @@ public class FileLink {
assert this.locations == null : "Link locations already set"; assert this.locations == null : "Link locations already set";
this.locations = new Path[1 + alternativePaths.length]; this.locations = new Path[1 + alternativePaths.length];
this.locations[0] = originPath; this.locations[0] = originPath;
for (int i = 0; i < alternativePaths.length; i++) { System.arraycopy(alternativePaths, 0, this.locations, 1, alternativePaths.length);
this.locations[i + 1] = alternativePaths[i];
}
} }
/** /**

View File

@ -171,8 +171,7 @@ public class SplitLogManager {
if (logfiles == null || logfiles.length == 0) { if (logfiles == null || logfiles.length == 0) {
LOG.info(hLogDir + " is empty dir, no logs to split"); LOG.info(hLogDir + " is empty dir, no logs to split");
} else { } else {
for (FileStatus status : logfiles) Collections.addAll(fileStatus, logfiles);
fileStatus.add(status);
} }
} }
FileStatus[] a = new FileStatus[fileStatus.size()]; FileStatus[] a = new FileStatus[fileStatus.size()];

View File

@ -898,9 +898,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
String[] tables = conf.getStrings( String[] tables = conf.getStrings(
"hbase.balancer.tablesOnMaster", DEFAULT_TABLES_ON_MASTER); "hbase.balancer.tablesOnMaster", DEFAULT_TABLES_ON_MASTER);
if (tables != null) { if (tables != null) {
for (String table: tables) { Collections.addAll(tablesOnMaster, tables);
tablesOnMaster.add(table);
}
} }
this.rackManager = new RackManager(getConf()); this.rackManager = new RackManager(getConf());
regionFinder.setConf(conf); regionFinder.setConf(conf);

View File

@ -1174,11 +1174,8 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
} }
// max cost is the case where every region replica is hosted together regardless of host // max cost is the case where every region replica is hosted together regardless of host
int[] primariesOfRegions = new int[cluster.numRegions]; int[] primariesOfRegions = new int[cluster.numRegions];
for (int i = 0; i < cluster.regions.length; i++) { System.arraycopy(cluster.regionIndexToPrimaryIndex, 0, primariesOfRegions, 0,
// assume all regions are hosted by only one server cluster.regions.length);
int primaryIndex = cluster.regionIndexToPrimaryIndex[i];
primariesOfRegions[i] = primaryIndex;
}
Arrays.sort(primariesOfRegions); Arrays.sort(primariesOfRegions);

View File

@ -161,7 +161,7 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase {
LOG.info("new MBeanInfo"); LOG.info("new MBeanInfo");
this.extendedInfo = new MBeanInfo( this.getClass().getName(), this.extendedInfo = new MBeanInfo( this.getClass().getName(),
this.description, attributes.toArray( new MBeanAttributeInfo[0] ), this.description, attributes.toArray(new MBeanAttributeInfo[attributes.size()]),
parentInfo.getConstructors(), parentInfo.getOperations(), parentInfo.getConstructors(), parentInfo.getOperations(),
parentInfo.getNotifications() ); parentInfo.getNotifications() );
} }

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@ -913,9 +914,7 @@ public class StripeStoreFileManager
if (this.state.stripeFiles.isEmpty()) return new ArrayList<byte[]>(); if (this.state.stripeFiles.isEmpty()) return new ArrayList<byte[]>();
ArrayList<byte[]> result = new ArrayList<byte[]>(this.state.stripeEndRows.length + 2); ArrayList<byte[]> result = new ArrayList<byte[]>(this.state.stripeEndRows.length + 2);
result.add(OPEN_KEY); result.add(OPEN_KEY);
for (int i = 0; i < this.state.stripeEndRows.length; ++i) { Collections.addAll(result, this.state.stripeEndRows);
result.add(this.state.stripeEndRows[i]);
}
result.add(OPEN_KEY); result.add(OPEN_KEY);
return result; return result;
} }

View File

@ -1221,7 +1221,7 @@ class FSHLog implements HLog, Syncable {
void offer(final long sequence, final SyncFuture [] syncFutures, final int syncFutureCount) { void offer(final long sequence, final SyncFuture [] syncFutures, final int syncFutureCount) {
// Set sequence first because the add to the queue will wake the thread if sleeping. // Set sequence first because the add to the queue will wake the thread if sleeping.
this.sequence = sequence; this.sequence = sequence;
for (int i = 0; i < syncFutureCount; i++) this.syncFutures.add(syncFutures[i]); this.syncFutures.addAll(Arrays.asList(syncFutures).subList(0, syncFutureCount));
} }
/** /**

View File

@ -19,6 +19,7 @@
package org.apache.hadoop.hbase.replication; package org.apache.hadoop.hbase.replication;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
@ -43,9 +44,7 @@ public class ChainWALEntryFilter implements WALEntryFilter {
// flatten the chains // flatten the chains
for (WALEntryFilter filter : filters) { for (WALEntryFilter filter : filters) {
if (filter instanceof ChainWALEntryFilter) { if (filter instanceof ChainWALEntryFilter) {
for (WALEntryFilter f : ((ChainWALEntryFilter) filter).filters) { Collections.addAll(rawFilters, ((ChainWALEntryFilter) filter).filters);
rawFilters.add(f);
}
} else { } else {
rawFilters.add(filter); rawFilters.add(filter);
} }

View File

@ -23,6 +23,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
@ -270,9 +271,7 @@ public class RowSpec {
this.row = startRow; this.row = startRow;
this.endRow = endRow; this.endRow = endRow;
if (columns != null) { if (columns != null) {
for (byte[] col: columns) { Collections.addAll(this.columns, columns);
this.columns.add(col);
}
} }
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.security.visibility.expression; package org.apache.hadoop.hbase.security.visibility.expression;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
@ -46,9 +47,7 @@ public class NonLeafExpressionNode implements ExpressionNode {
public NonLeafExpressionNode(Operator op, ExpressionNode... exps) { public NonLeafExpressionNode(Operator op, ExpressionNode... exps) {
this.op = op; this.op = op;
List<ExpressionNode> expLst = new ArrayList<ExpressionNode>(); List<ExpressionNode> expLst = new ArrayList<ExpressionNode>();
for (ExpressionNode exp : exps) { Collections.addAll(expLst, exps);
expLst.add(exp);
}
this.childExps = expLst; this.childExps = expLst;
} }

View File

@ -68,9 +68,7 @@ public class CollectionBackedScanner extends NonReversedNonLazyKeyValueScanner {
this.comparator = comparator; this.comparator = comparator;
List<KeyValue> tmp = new ArrayList<KeyValue>(array.length); List<KeyValue> tmp = new ArrayList<KeyValue>(array.length);
for( int i = 0; i < array.length ; ++i) { Collections.addAll(tmp, array);
tmp.add(array[i]);
}
Collections.sort(tmp, comparator); Collections.sort(tmp, comparator);
data = tmp; data = tmp;
init(); init();

View File

@ -1298,7 +1298,7 @@ public class HBaseFsck extends Configured {
"You may need to restore the previously sidelined hbase:meta"); "You may need to restore the previously sidelined hbase:meta");
return false; return false;
} }
meta.batchMutate(puts.toArray(new Put[0])); meta.batchMutate(puts.toArray(new Put[puts.size()]));
HRegion.closeHRegion(meta); HRegion.closeHRegion(meta);
LOG.info("Success! hbase:meta table rebuilt."); LOG.info("Success! hbase:meta table rebuilt.");
LOG.info("Old hbase:meta is moved into " + backupDir); LOG.info("Old hbase:meta is moved into " + backupDir);

View File

@ -129,9 +129,7 @@ public class MunkresAssignment {
} }
} else { } else {
for (int r = 0; r < rows; r++) { for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) { System.arraycopy(costMatrix[r], 0, cost[r], 0, cols);
cost[r][c] = costMatrix[r][c];
}
} }
} }

View File

@ -681,7 +681,7 @@ public class RegionSplitter {
LinkedList<HRegionInfo> check = Lists.newLinkedList(); LinkedList<HRegionInfo> check = Lists.newLinkedList();
check.add(table.getRegionLocation(start).getRegionInfo()); check.add(table.getRegionLocation(start).getRegionInfo());
check.add(table.getRegionLocation(split).getRegionInfo()); check.add(table.getRegionLocation(split).getRegionInfo());
for (HRegionInfo hri : check.toArray(new HRegionInfo[] {})) { for (HRegionInfo hri : check.toArray(new HRegionInfo[check.size()])) {
byte[] sk = hri.getStartKey(); byte[] sk = hri.getStartKey();
if (sk.length == 0) if (sk.length == 0)
sk = splitAlgo.firstRow(); sk = splitAlgo.firstRow();

View File

@ -2074,9 +2074,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
byte [] endKey = Bytes.toBytes("zzzzz"); byte [] endKey = Bytes.toBytes("zzzzz");
byte [][] splitKeys = Bytes.split(startKey, endKey, numRegions - 3); byte [][] splitKeys = Bytes.split(startKey, endKey, numRegions - 3);
byte [][] regionStartKeys = new byte[splitKeys.length+1][]; byte [][] regionStartKeys = new byte[splitKeys.length+1][];
for (int i=0;i<splitKeys.length;i++) { System.arraycopy(splitKeys, 0, regionStartKeys, 1, splitKeys.length);
regionStartKeys[i+1] = splitKeys[i];
}
regionStartKeys[0] = HConstants.EMPTY_BYTE_ARRAY; regionStartKeys[0] = HConstants.EMPTY_BYTE_ARRAY;
return createMultiRegions(c, table, family, regionStartKeys); return createMultiRegions(c, table, family, regionStartKeys);
} }
@ -3085,9 +3083,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
assertTrue(numRegions>3); assertTrue(numRegions>3);
byte [][] tmpSplitKeys = Bytes.split(startKey, endKey, numRegions - 3); byte [][] tmpSplitKeys = Bytes.split(startKey, endKey, numRegions - 3);
byte [][] result = new byte[tmpSplitKeys.length+1][]; byte [][] result = new byte[tmpSplitKeys.length+1][];
for (int i=0;i<tmpSplitKeys.length;i++) { System.arraycopy(tmpSplitKeys, 0, result, 1, tmpSplitKeys.length);
result[i+1] = tmpSplitKeys[i];
}
result[0] = HConstants.EMPTY_BYTE_ARRAY; result[0] = HConstants.EMPTY_BYTE_ARRAY;
return result; return result;
} }
@ -3599,6 +3595,6 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
// this algo is not available // this algo is not available
} }
} }
return supportedAlgos.toArray(new Compression.Algorithm[0]); return supportedAlgos.toArray(new Algorithm[supportedAlgos.size()]);
} }
} }

View File

@ -33,6 +33,7 @@ import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -4073,9 +4074,7 @@ public class TestFromClientSide {
Admin admin = new HBaseAdmin(TEST_UTIL.getConfiguration()); Admin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
HTableDescriptor[] ts = admin.listTables(); HTableDescriptor[] ts = admin.listTables();
HashSet<HTableDescriptor> result = new HashSet<HTableDescriptor>(ts.length); HashSet<HTableDescriptor> result = new HashSet<HTableDescriptor>(ts.length);
for (int i = 0; i < ts.length; i++) { Collections.addAll(result, ts);
result.add(ts[i]);
}
int size = result.size(); int size = result.size();
assertTrue(size >= tables.length); assertTrue(size >= tables.length);
for (int i = 0; i < tables.length && i < size; i++) { for (int i = 0; i < tables.length && i < size; i++) {

View File

@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -193,9 +194,7 @@ public class TestSnapshotMetadata {
// restore the snapshot into a cloned table and examine the output // restore the snapshot into a cloned table and examine the output
List<byte[]> familiesList = new ArrayList<byte[]>(); List<byte[]> familiesList = new ArrayList<byte[]>();
for (byte[] family : families) { Collections.addAll(familiesList, families);
familiesList.add(family);
}
// Create a snapshot in which all families are empty // Create a snapshot in which all families are empty
SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName, null, SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName, null,
@ -277,9 +276,7 @@ public class TestSnapshotMetadata {
} }
familiesWithDataList.add(familyForUpdate); familiesWithDataList.add(familyForUpdate);
} else { } else {
for (byte[] family : families) { Collections.addAll(emptyFamiliesList, families);
emptyFamiliesList.add(family);
}
} }
// take a "disabled" snapshot // take a "disabled" snapshot

View File

@ -87,33 +87,33 @@ public class TestInvocationRecordFilter {
List<Integer> expectedQualifiers = new ArrayList<Integer>(); List<Integer> expectedQualifiers = new ArrayList<Integer>();
selectQualifiers.add(-1); selectQualifiers.add(-1);
verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]),
expectedQualifiers.toArray(new Integer[0])); expectedQualifiers.toArray(new Integer[expectedQualifiers.size()]));
selectQualifiers.clear(); selectQualifiers.clear();
selectQualifiers.add(0); selectQualifiers.add(0);
expectedQualifiers.add(0); expectedQualifiers.add(0);
verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]),
expectedQualifiers.toArray(new Integer[0])); expectedQualifiers.toArray(new Integer[expectedQualifiers.size()]));
selectQualifiers.add(3); selectQualifiers.add(3);
verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]),
expectedQualifiers.toArray(new Integer[0])); expectedQualifiers.toArray(new Integer[expectedQualifiers.size()]));
selectQualifiers.add(4); selectQualifiers.add(4);
expectedQualifiers.add(4); expectedQualifiers.add(4);
verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]),
expectedQualifiers.toArray(new Integer[0])); expectedQualifiers.toArray(new Integer[expectedQualifiers.size()]));
selectQualifiers.add(5); selectQualifiers.add(5);
verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]),
expectedQualifiers.toArray(new Integer[0])); expectedQualifiers.toArray(new Integer[expectedQualifiers.size()]));
selectQualifiers.add(8); selectQualifiers.add(8);
expectedQualifiers.add(8); expectedQualifiers.add(8);
verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]),
expectedQualifiers.toArray(new Integer[0])); expectedQualifiers.toArray(new Integer[expectedQualifiers.size()]));
} }
public void verifyInvocationResults(Integer[] selectQualifiers, public void verifyInvocationResults(Integer[] selectQualifiers,

View File

@ -655,9 +655,7 @@ public class TestStripeCompactionPolicy {
byte[][] keys = new byte[][] { KEY_A, KEY_B, KEY_C, KEY_D, KEY_E }; byte[][] keys = new byte[][] { KEY_A, KEY_B, KEY_C, KEY_D, KEY_E };
assert stripeCount <= keys.length + 1; assert stripeCount <= keys.length + 1;
List<byte[]> boundaries = new ArrayList<byte[]>(); List<byte[]> boundaries = new ArrayList<byte[]>();
for (int i = 0; i < stripeCount - 1; ++i) { boundaries.addAll(Arrays.asList(keys).subList(0, stripeCount - 1));
boundaries.add(keys[i]);
}
return boundaries; return boundaries;
} }

View File

@ -134,11 +134,13 @@ public class TestUser {
final String username = "testuser"; final String username = "testuser";
final ImmutableSet<String> singleGroups = ImmutableSet.of("group"); final ImmutableSet<String> singleGroups = ImmutableSet.of("group");
final Configuration conf = HBaseConfiguration.create(); final Configuration conf = HBaseConfiguration.create();
User user = User.createUserForTesting(conf, username, singleGroups.toArray(new String[]{})); User user = User.createUserForTesting(conf, username,
singleGroups.toArray(new String[singleGroups.size()]));
assertUserGroup(user, singleGroups); assertUserGroup(user, singleGroups);
final ImmutableSet<String> multiGroups = ImmutableSet.of("group", "group1", "group2"); final ImmutableSet<String> multiGroups = ImmutableSet.of("group", "group1", "group2");
user = User.createUserForTesting(conf, username, multiGroups.toArray(new String[]{})); user = User.createUserForTesting(conf, username,
multiGroups.toArray(new String[multiGroups.size()]));
assertUserGroup(user, multiGroups); assertUserGroup(user, multiGroups);
} }

View File

@ -757,9 +757,7 @@ public class LoadTestTool extends AbstractHBaseTool {
newArgs = new String[cmdLineArgs.length + 2]; newArgs = new String[cmdLineArgs.length + 2];
newArgs[0] = "-" + LoadTestTool.OPT_TABLE_NAME; newArgs[0] = "-" + LoadTestTool.OPT_TABLE_NAME;
newArgs[1] = LoadTestTool.DEFAULT_TABLE_NAME; newArgs[1] = LoadTestTool.DEFAULT_TABLE_NAME;
for (int i = 0; i < cmdLineArgs.length; i++) { System.arraycopy(cmdLineArgs, 0, newArgs, 2, cmdLineArgs.length);
newArgs[i + 2] = cmdLineArgs[i];
}
} else { } else {
newArgs = cmdLineArgs; newArgs = cmdLineArgs;
} }

View File

@ -693,8 +693,8 @@ public class TestHBaseFsck {
} }
} }
Put put = new Put(metaKey); Put put = new Put(metaKey);
ServerName sn = TEST_UTIL.getHBaseAdmin().getClusterStatus().getServers() Collection<ServerName> var = TEST_UTIL.getHBaseAdmin().getClusterStatus().getServers();
.toArray(new ServerName[0])[0]; ServerName sn = var.toArray(new ServerName[var.size()])[0];
//add a location with replicaId as 2 (since we already have replicas with replicaid 0 and 1) //add a location with replicaId as 2 (since we already have replicas with replicaid 0 and 1)
MetaTableAccessor.addLocation(put, sn, sn.getStartcode(), 2); MetaTableAccessor.addLocation(put, sn, sn.getStartcode(), 2);
meta.put(put); meta.put(put);

View File

@ -173,7 +173,7 @@ public class TestThriftServerCmdLine {
args.add("start"); args.add("start");
thriftServer = new ThriftServer(TEST_UTIL.getConfiguration()); thriftServer = new ThriftServer(TEST_UTIL.getConfiguration());
startCmdLineThread(args.toArray(new String[0])); startCmdLineThread(args.toArray(new String[args.size()]));
// wait up to 10s for the server to start // wait up to 10s for the server to start
for (int i = 0; i < 100 for (int i = 0; i < 100