Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@ public int getTotalRows() {
return totalRows;
}

public int getClients() {
return clients;
}

public boolean isFlushCommits() {
return flushCommits;
}
Expand Down Expand Up @@ -486,11 +482,11 @@ private <Type> Class<? extends Type> forName(String className, Class<Type> type)

@Override
protected void map(NullWritable key, PeInputSplit value, final Context context)
throws IOException, InterruptedException {
throws IOException, InterruptedException {
Status status = new Status() {
@Override
public void setStatus(String msg) {
context.setStatus(msg);
context.setStatus(msg);
}
};

Expand Down Expand Up @@ -631,7 +627,7 @@ public void run() {
perClientRows, R,
flushCommits, writeToWAL, useTags, noOfTags, connection, new Status() {
@Override
public void setStatus(final String msg) throws IOException {
public void setStatus(final String msg) {
LOG.info("client-" + getName() + " " + msg);
}
});
Expand Down Expand Up @@ -781,21 +777,19 @@ static class TestOptions {
private int startRow;
private int perClientRunRows;
private int totalRows;
private int numClientThreads;
private TableName tableName;
private boolean flushCommits;
private boolean writeToWAL;
private boolean useTags;
private int noOfTags;
private Connection connection;

TestOptions(int startRow, int perClientRunRows, int totalRows, int numClientThreads,
TableName tableName, boolean flushCommits, boolean writeToWAL, boolean useTags,
TestOptions(int startRow, int perClientRunRows, int totalRows, TableName tableName,
boolean flushCommits, boolean writeToWAL, boolean useTags,
int noOfTags, Connection connection) {
this.startRow = startRow;
this.perClientRunRows = perClientRunRows;
this.totalRows = totalRows;
this.numClientThreads = numClientThreads;
this.tableName = tableName;
this.flushCommits = flushCommits;
this.writeToWAL = writeToWAL;
Expand All @@ -816,10 +810,6 @@ public int getTotalRows() {
return totalRows;
}

public int getNumClientThreads() {
return numClientThreads;
}

public TableName getTableName() {
return tableName;
}
Expand Down Expand Up @@ -1286,7 +1276,7 @@ long runOneClient(final Class<? extends Test> cmd, final int startRow,
long totalElapsedTime;

TestOptions options = new TestOptions(startRow, perClientRunRows,
totalRows, N, tableName, flushCommits, writeToWAL, useTags, noOfTags, connection);
totalRows, tableName, flushCommits, writeToWAL, useTags, noOfTags, connection);
final Test t;
try {
Constructor<? extends Test> constructor = cmd.getDeclaredConstructor(
Expand All @@ -1310,7 +1300,7 @@ long runOneClient(final Class<? extends Test> cmd, final int startRow,
private void runNIsOne(final Class<? extends Test> cmd) {
Status status = new Status() {
@Override
public void setStatus(String msg) throws IOException {
public void setStatus(String msg) {
LOG.info(msg);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.hbase.rest;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -46,7 +45,6 @@

@Category(MediumTests.class)
public class TestGetAndPutResource extends RowResourceBase {

private static final MetricsAssertHelper METRICS_ASSERT =
CompatibilityFactory.getInstance(MetricsAssertHelper.class);

Expand Down Expand Up @@ -110,7 +108,7 @@ public void testSingleCellGetPutXML() throws IOException, JAXBException {
public void testSingleCellGetPutPB() throws IOException, JAXBException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());

response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
assertEquals(200, response.getCode());
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
Expand All @@ -130,7 +128,7 @@ public void testSingleCellGetPutPB() throws IOException, JAXBException {
}

@Test
public void testMultipleCellCheckPutPB() throws IOException, JAXBException {
public void testMultipleCellCheckPutPB() throws IOException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());

Expand All @@ -143,7 +141,7 @@ public void testMultipleCellCheckPutPB() throws IOException, JAXBException {
assertEquals(200, response.getCode());
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);

HashMap<String,String> otherCells = new HashMap<String, String>();
HashMap<String,String> otherCells = new HashMap<>();
otherCells.put(COLUMN_2,VALUE_3);

// On Success update both the cells
Expand Down Expand Up @@ -176,7 +174,7 @@ public void testMultipleCellCheckPutXML() throws IOException, JAXBException {
assertEquals(200, response.getCode());
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);

HashMap<String,String> otherCells = new HashMap<String, String>();
HashMap<String,String> otherCells = new HashMap<>();
otherCells.put(COLUMN_2,VALUE_3);

// On Success update both the cells
Expand All @@ -196,7 +194,7 @@ public void testMultipleCellCheckPutXML() throws IOException, JAXBException {
}

@Test
public void testMultipleCellCheckDeletePB() throws IOException, JAXBException {
public void testMultipleCellCheckDeletePB() throws IOException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());

Expand All @@ -214,7 +212,7 @@ public void testMultipleCellCheckDeletePB() throws IOException, JAXBException {
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);

// Deletes the following columns based on Column1 check
HashMap<String,String> cellsToDelete = new HashMap<String, String>();
HashMap<String,String> cellsToDelete = new HashMap<>();
cellsToDelete.put(COLUMN_2,VALUE_2); // Value does not matter
cellsToDelete.put(COLUMN_3,VALUE_3); // Value does not matter

Expand Down Expand Up @@ -249,7 +247,7 @@ public void testMultipleCellCheckDeletePB() throws IOException, JAXBException {
assertEquals(200, response.getCode());
}

@Test
@Test
public void testSingleCellGetPutBinary() throws IOException {
final String path = "/" + TABLE + "/" + ROW_3 + "/" + COLUMN_1;
final byte[] body = Bytes.toBytes(VALUE_3);
Expand All @@ -275,7 +273,7 @@ public void testSingleCellGetPutBinary() throws IOException {
}

@Test
public void testSingleCellGetJSON() throws IOException, JAXBException {
public void testSingleCellGetJSON() throws IOException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
Response response = client.put(path, Constants.MIMETYPE_BINARY,
Bytes.toBytes(VALUE_4));
Expand All @@ -289,7 +287,7 @@ public void testSingleCellGetJSON() throws IOException, JAXBException {
}

@Test
public void testLatestCellGetJSON() throws IOException, JAXBException {
public void testLatestCellGetJSON() throws IOException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_4);
Expand Down Expand Up @@ -336,7 +334,7 @@ public void testURLEncodedKey() throws IOException, JAXBException {
}

@Test
public void testNoSuchCF() throws IOException, JAXBException {
public void testNoSuchCF() throws IOException {
final String goodPath = "/" + TABLE + "/" + ROW_1 + "/" + CFA+":";
final String badPath = "/" + TABLE + "/" + ROW_1 + "/" + "BAD";
Response response = client.post(goodPath, Constants.MIMETYPE_BINARY,
Expand Down Expand Up @@ -524,9 +522,9 @@ public void testMultiCellGetJson() throws IOException, JAXBException {
response = deleteRow(TABLE, ROW_2);
assertEquals(200, response.getCode());
}

@Test
public void testMetrics() throws IOException, JAXBException {
public void testMetrics() throws IOException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
Response response = client.put(path, Constants.MIMETYPE_BINARY,
Bytes.toBytes(VALUE_4));
Expand All @@ -539,19 +537,19 @@ public void testMetrics() throws IOException, JAXBException {
assertEquals(200, response.getCode());

UserProvider userProvider = UserProvider.instantiate(conf);
METRICS_ASSERT.assertCounterGt("requests", 2l,
METRICS_ASSERT.assertCounterGt("requests", 2L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());

METRICS_ASSERT.assertCounterGt("successfulGet", 0l,
METRICS_ASSERT.assertCounterGt("successfulGet", 0L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());

METRICS_ASSERT.assertCounterGt("successfulPut", 0l,
METRICS_ASSERT.assertCounterGt("successfulPut", 0L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());

METRICS_ASSERT.assertCounterGt("successfulDelete", 0l,
METRICS_ASSERT.assertCounterGt("successfulDelete", 0L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
}

@Test
public void testMultiColumnGetXML() throws Exception {
String path = "/" + TABLE + "/fakerow";
Expand All @@ -575,8 +573,8 @@ public void testMultiColumnGetXML() throws Exception {
path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "," + COLUMN_2 + "," + COLUMN_3;
response = client.get(path, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response
.getBody()));
CellSetModel cellSet =
(CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
assertTrue(cellSet.getRows().size() == 1);
assertTrue(cellSet.getRows().get(0).getCells().size() == 3);
List<CellModel> cells = cellSet.getRows().get(0).getCells();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* 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
Expand All @@ -18,6 +17,11 @@
*/
package org.apache.hadoop.hbase.rest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -51,8 +55,6 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;

import static org.junit.Assert.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -61,13 +63,13 @@
@Category(MediumTests.class)
public class TestNamespacesInstanceResource {
private static String NAMESPACE1 = "TestNamespacesInstanceResource1";
private static Map<String,String> NAMESPACE1_PROPS = new HashMap<String,String>();
private static Map<String,String> NAMESPACE1_PROPS = new HashMap<>();
private static String NAMESPACE2 = "TestNamespacesInstanceResource2";
private static Map<String,String> NAMESPACE2_PROPS = new HashMap<String,String>();
private static Map<String,String> NAMESPACE2_PROPS = new HashMap<>();
private static String NAMESPACE3 = "TestNamespacesInstanceResource3";
private static Map<String,String> NAMESPACE3_PROPS = new HashMap<String,String>();
private static Map<String,String> NAMESPACE3_PROPS = new HashMap<>();
private static String NAMESPACE4 = "TestNamespacesInstanceResource4";
private static Map<String,String> NAMESPACE4_PROPS = new HashMap<String,String>();
private static Map<String,String> NAMESPACE4_PROPS = new HashMap<>();

private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static final HBaseRESTTestingUtility REST_TEST_UTIL =
Expand All @@ -87,8 +89,8 @@ public static void setUpBeforeClass() throws Exception {
REST_TEST_UTIL.getServletPort()));
testNamespacesInstanceModel = new TestNamespacesInstanceModel();
context = JAXBContext.newInstance(NamespacesInstanceModel.class, TableListModel.class);
jsonMapper = new JacksonProvider()
.locateMapper(NamespacesInstanceModel.class, MediaType.APPLICATION_JSON_TYPE);
jsonMapper = new JacksonProvider().locateMapper(NamespacesInstanceModel.class,
MediaType.APPLICATION_JSON_TYPE);
NAMESPACE1_PROPS.put("key1", "value1");
NAMESPACE2_PROPS.put("key2a", "value2a");
NAMESPACE2_PROPS.put("key2b", "value2b");
Expand Down Expand Up @@ -117,9 +119,9 @@ private static <T> T fromXML(byte[] content)

private NamespaceDescriptor findNamespace(Admin admin, String namespaceName) throws IOException{
NamespaceDescriptor[] nd = admin.listNamespaceDescriptors();
for(int i = 0; i < nd.length; i++){
if(nd[i].getName().equals(namespaceName)){
return nd[i];
for (NamespaceDescriptor namespaceDescriptor : nd) {
if (namespaceDescriptor.getName().equals(namespaceName)) {
return namespaceDescriptor;
}
}
return null;
Expand All @@ -129,18 +131,18 @@ private void checkNamespaceProperties(NamespaceDescriptor nd, Map<String,String>
checkNamespaceProperties(nd.getConfiguration(), testProps);
}

private void checkNamespaceProperties(Map<String,String> namespaceProps,
private void checkNamespaceProperties(Map<String,String> namespaceProps,
Map<String,String> testProps){
assertTrue(namespaceProps.size() == testProps.size());
for(String key: testProps.keySet()){
for (String key: testProps.keySet()) {
assertEquals(testProps.get(key), namespaceProps.get(key));
}
}

private void checkNamespaceTables(List<TableModel> namespaceTables, List<String> testTables){
assertEquals(namespaceTables.size(), testTables.size());
for(int i = 0 ; i < namespaceTables.size() ; i++){
String tableName = ((TableModel) namespaceTables.get(i)).getName();
for (TableModel namespaceTable : namespaceTables) {
String tableName = namespaceTable.getName();
assertTrue(testTables.contains(tableName));
}
}
Expand Down Expand Up @@ -174,7 +176,7 @@ public void testGetNamespaceTablesAndCannotDeleteNamespace() throws IOException,

// Create namespace via admin.
NamespaceDescriptor.Builder nsBuilder = NamespaceDescriptor.create(nsName);
NamespaceDescriptor nsd = nsBuilder.build();
NamespaceDescriptor nsd = nsBuilder.build();
nsd.setConfiguration("key1", "value1");
admin.createNamespace(nsd);

Expand All @@ -189,7 +191,7 @@ public void testGetNamespaceTablesAndCannotDeleteNamespace() throws IOException,
table.addFamily(colDesc);
admin.createTable(table);

Map<String, String> nsProperties = new HashMap<String,String>();
Map<String, String> nsProperties = new HashMap<>();
nsProperties.put("key1", "value1");
List<String> nsTables = Arrays.asList("table1", "table2");

Expand Down Expand Up @@ -357,7 +359,7 @@ public void testNamespaceCreateAndDeleteXMLAndJSON() throws IOException, JAXBExc
}

@Test
public void testNamespaceCreateAndDeletePBAndNoBody() throws IOException, JAXBException {
public void testNamespaceCreateAndDeletePBAndNoBody() throws IOException {
String namespacePath3 = "/namespaces/" + NAMESPACE3;
String namespacePath4 = "/namespaces/" + NAMESPACE4;
NamespacesInstanceModel model3;
Expand Down Expand Up @@ -412,7 +414,7 @@ public void testNamespaceCreateAndDeletePBAndNoBody() throws IOException, JAXBEx
// Check cannot post tables that already exist.
response = client.post(namespacePath3, Constants.MIMETYPE_BINARY, new byte[]{});
assertEquals(403, response.getCode());
response = client.post(namespacePath4, Constants.MIMETYPE_PROTOBUF,
response = client.post(namespacePath4, Constants.MIMETYPE_PROTOBUF,
model4.createProtobufOutput());
assertEquals(403, response.getCode());

Expand Down
Loading