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 @@ -18,19 +18,13 @@

package org.apache.hadoop.hive.common.jsonexplain.tez;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import org.apache.hadoop.hive.common.jsonexplain.tez.Op.OpType;
import org.apache.hadoop.util.hash.Hash;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -98,16 +92,11 @@ public void addDependency(Connection connection) throws JSONException {
}

/**
* @throws JSONException
* @throws JsonParseException
* @throws JsonMappingException
* @throws IOException
* @throws Exception
* We assume that there is a single top-level Map Operator Tree or a
* Reduce Operator Tree in a vertex
*/
public void extractOpTree() throws JSONException, JsonParseException, JsonMappingException,
IOException, Exception {
public void extractOpTree() throws Exception {
if (vertexObject.length() != 0) {
for (String key : JSONObject.getNames(vertexObject)) {
if (key.equals("Map Operator Tree:")) {
Expand Down Expand Up @@ -152,16 +141,11 @@ public void extractOpTree() throws JSONException, JsonParseException, JsonMappin
* @param operator
* @param parent
* @return
* @throws JSONException
* @throws JsonParseException
* @throws JsonMappingException
* @throws IOException
* @throws Exception
* assumption: each operator only has one parent but may have many
* children
*/
Op extractOp(JSONObject operator) throws JSONException, JsonParseException, JsonMappingException,
IOException, Exception {
Op extractOp(JSONObject operator) throws Exception {
String[] names = JSONObject.getNames(operator);
if (names.length != 1) {
throw new Exception("Expect only one operator in " + operator.toString());
Expand Down Expand Up @@ -214,8 +198,7 @@ Op extractOp(JSONObject operator) throws JSONException, JsonParseException, Json
}
}

public void print(Printer printer, int indentFlag, String type, Vertex callingVertex)
throws JSONException, Exception {
public void print(Printer printer, int indentFlag, String type, Vertex callingVertex) throws Exception {
// print vertexname
if (parser.printSet.contains(this) && !hasMultiReduceOp) {
if (type != null) {
Expand Down
29 changes: 15 additions & 14 deletions common/src/java/org/apache/hive/http/JMXJsonServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerator;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;

/*
* This servlet is based off of the JMXProxyServlet from Tomcat 7.0.14. It has
Expand All @@ -72,7 +73,7 @@
* attribute of a JMX bean. The format of the URL is
* <code>http://.../jmx?get=MXBeanName::AttributeName<code>
* <p>
* For example
* For example
* <code>
* http://../jmx?get=Hadoop:service=NameNode,name=NameNodeInfo::ClusterId
* </code> will return the cluster id of the namenode mxbean.
Expand All @@ -98,23 +99,23 @@
* <p>
* The servlet attempts to convert the JMXBeans into JSON. Each
* bean's attributes will be converted to a JSON object member.
*
*
* If the attribute is a boolean, a number, a string, or an array
* it will be converted to the JSON equivalent.
*
* it will be converted to the JSON equivalent.
*
* If the value is a {@link CompositeData} then it will be converted
* to a JSON object with the keys as the name of the JSON member and
* the value is converted following these same rules.
*
*
* If the value is a {@link TabularData} then it will be converted
* to an array of the {@link CompositeData} elements that it contains.
*
*
* All other objects will be converted to a string and output as such.
*
*
* The bean's name and modelerType will be returned for all beans.
*
* Optional paramater "callback" should be used to deliver JSONP response.
*
*
*/
public class JMXJsonServlet extends HttpServlet {
private static final Log LOG = LogFactory.getLog(JMXJsonServlet.class);
Expand Down Expand Up @@ -144,7 +145,7 @@ public void init() throws ServletException {

/**
* Process a GET request for the specified resource.
*
*
* @param request
* The servlet request we are processing
* @param response
Expand Down Expand Up @@ -210,8 +211,8 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {
}

// --------------------------------------------------------- Private Methods
private void listBeans(JsonGenerator jg, ObjectName qry, String attribute,
HttpServletResponse response)
private void listBeans(JsonGenerator jg, ObjectName qry, String attribute,
HttpServletResponse response)
throws IOException {
LOG.debug("Listing beans for "+qry);
Set<ObjectName> names = null;
Expand Down Expand Up @@ -255,7 +256,7 @@ private void listBeans(JsonGenerator jg, ObjectName qry, String attribute,
+ " threw an exception", e);
} catch ( ReflectionException e ) {
// This happens when the code inside the JMX bean (setter?? from the
// java docs) threw an exception, so log it and fall back on the
// java docs) threw an exception, so log it and fall back on the
// class name
LOG.error("getting attribute " + prs + " of " + oname
+ " threw an exception", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@
import org.apache.hive.hcatalog.data.schema.HCatFieldSchema.Type;
import org.apache.hive.hcatalog.data.schema.HCatSchema;
import org.apache.hive.hcatalog.data.schema.HCatSchemaUtils;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;

@SerDeSpec(schemaProps = {serdeConstants.LIST_COLUMNS,
serdeConstants.LIST_COLUMN_TYPES,
serdeConstants.TIMESTAMP_FORMATS})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.hive.hcatalog.messaging.json;

import org.apache.hive.hcatalog.messaging.AddPartitionMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.hive.hcatalog.messaging.AlterIndexMessage;
import org.apache.thrift.TException;

import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON Implementation of AlterIndexMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.hive.hcatalog.common.HCatConstants;
import org.apache.hive.hcatalog.messaging.AlterPartitionMessage;
import org.apache.hive.hcatalog.messaging.AlterTableMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hive.hcatalog.common.HCatConstants;
import org.apache.hive.hcatalog.messaging.AlterTableMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.hive.hcatalog.messaging.json;

import org.apache.hive.hcatalog.messaging.CreateDatabaseMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON Implementation of CreateDatabaseMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.hadoop.hive.metastore.api.Function;
import org.apache.hive.hcatalog.messaging.CreateFunctionMessage;
import org.apache.thrift.TException;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON Implementation of CreateFunctionMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.hadoop.hive.metastore.api.Index;
import org.apache.hive.hcatalog.messaging.CreateIndexMessage;
import org.apache.thrift.TException;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON Implementation of CreateIndexMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.hive.hcatalog.messaging.json;

import org.apache.hive.hcatalog.messaging.CreateTableMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON implementation of CreateTableMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.hive.hcatalog.messaging.json;

import org.apache.hive.hcatalog.messaging.DropDatabaseMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON implementation of DropDatabaseMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.hadoop.hive.metastore.api.Function;
import org.apache.hive.hcatalog.messaging.DropFunctionMessage;
import org.apache.thrift.TException;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON Implementation of CreateDatabaseMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.hadoop.hive.metastore.api.Index;
import org.apache.hive.hcatalog.messaging.DropIndexMessage;
import org.apache.thrift.TException;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON Implementation of DropIndexMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.hive.hcatalog.messaging.json;

import org.apache.hive.hcatalog.messaging.DropPartitionMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.hive.hcatalog.messaging.json;

import org.apache.hive.hcatalog.messaging.DropTableMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* JSON implementation of DropTableMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.hive.hcatalog.messaging.json;

import org.apache.hive.hcatalog.messaging.InsertMessage;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
import org.apache.hive.hcatalog.messaging.DropTableMessage;
import org.apache.hive.hcatalog.messaging.InsertMessage;
import org.apache.hive.hcatalog.messaging.MessageDeserializer;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* MessageDeserializer implementation, for deserializing from JSON strings.
Expand All @@ -45,7 +46,7 @@ public class JSONMessageDeserializer extends MessageDeserializer {
static ObjectMapper mapper = new ObjectMapper(); // Thread-safe.

static {
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hive.hcatalog.templeton.tool.TempletonUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.eclipse.jetty.http.HttpStatus;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
* Helper class to build new json objects with new top level
* properties. Only add non-null entries.
Expand Down Expand Up @@ -93,8 +94,9 @@ public static JsonBuilder createError(String msg, int errorCode)
* Add a non-null value to the map.
*/
public JsonBuilder put(String name, Object val) {
if (val != null)
if (val != null) {
map.put(name, val);
}
return this;
}

Expand Down Expand Up @@ -134,7 +136,9 @@ public String buildJson()
public Response buildResponse() {
int status = HttpStatus.OK_200; // Server ok.
if (map.containsKey("error"))
{
status = HttpStatus.INTERNAL_SERVER_ERROR_500; // Generic http server error.
}
Object o = map.get("errorCode");
if (o != null) {
if(hiveError2HttpStatusCode.containsKey(o)) {
Expand Down Expand Up @@ -173,9 +177,9 @@ public static boolean isError(Map obj) {
*/
public static Map jsonToMap(String json)
throws IOException {
if (!TempletonUtils.isset(json))
if (!TempletonUtils.isset(json)) {
return new HashMap<String, Object>();
else {
} else {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(json, Map.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.codehaus.jackson.map.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* Simple exception that will return a json error payload if thrown
Expand Down Expand Up @@ -55,8 +55,9 @@ public static Response buildMessage(int httpCode, Map<String, Object> params,
String msg) {
HashMap<String, Object> err = new HashMap<String, Object>();
err.put("error", msg);
if (params != null)
if (params != null) {
err.putAll(params);
}

String json = "\"error\"";
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
import org.codehaus.jackson.map.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* TestDesc - Test the desc objects that are correctly converted to
Expand Down
Loading