You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by om...@apache.org on 2011/12/14 00:06:52 UTC
svn commit: r1213977 - in /incubator/ambari/trunk: ./
client/src/main/java/org/apache/ambari/common/rest/agent/
client/src/main/java/org/apache/ambari/common/rest/entities/
controller/src/main/java/org/apache/ambari/controller/rest/agent/
controller/sr...
Author: omalley
Date: Tue Dec 13 23:06:51 2011
New Revision: 1213977
URL: http://svn.apache.org/viewvc?rev=1213977&view=rev
Log:
AMBARI-158. Move the JSON encoding to the natural one. (omalley)
Added:
incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/agent/package.html
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java
Removed:
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/config/ContextProvider.java
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/package.html
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/AgentJAXBContextResolver.java
incubator/ambari/trunk/controller/src/main/resources/WEB-INF/web.xml
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1213977&r1=1213976&r2=1213977&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Dec 13 23:06:51 2011
@@ -1,6 +1,8 @@
Ambari Change log
Release 0.1.0 - unreleased
+
+ AMBARI-158. Move the JSON encoding to the natural one. (omalley)
AMBARI-157. Enhances the agent to make it puppet aware (ddas)
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/agent/package.html
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/agent/package.html?rev=1213977&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/agent/package.html (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/agent/package.html Tue Dec 13 23:06:51 2011
@@ -0,0 +1,30 @@
+<!--
+ * 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.
+ -->
+ <html>
+ <head><title>Ambari Agent-Controller REST entities</title></head>
+ <body>
+ <p>
+ These are the entities that are used for the internal Ambari Agent to
+ Controller communication.
+ </p>
+ <p>
+ Any new classes that are added, must be manually inserted into
+ org.apache.ambari.controller.reset.agent.AgentJAXBContextResolver.
+ </p>
+ </body>
+ </html>
\ No newline at end of file
Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/package.html
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/package.html?rev=1213977&r1=1213976&r2=1213977&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/package.html (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/package.html Tue Dec 13 23:06:51 2011
@@ -34,5 +34,10 @@ have the
<a href="http://relaxng.org/compact-tutorial-20030326.html">compact RelaxNG</a>
schemas for their type.
</p>
+
+<p>
+ Any new classes that are added, must be manually inserted into
+ org.apache.ambari.controller.rest.resources.ContextProvider.
+</p>
</body>
</html>
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/AgentJAXBContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/AgentJAXBContextResolver.java?rev=1213977&r1=1213976&r2=1213977&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/AgentJAXBContextResolver.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/AgentJAXBContextResolver.java Tue Dec 13 23:06:51 2011
@@ -18,47 +18,34 @@
package org.apache.ambari.controller.rest.agent;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.api.json.JSONJAXBContext;
-import org.apache.ambari.common.rest.agent.Command;
-import org.apache.ambari.common.rest.agent.HeartBeat;
-import org.apache.ambari.common.rest.agent.ControllerResponse;
-import org.apache.ambari.common.rest.agent.Action;
-import org.apache.ambari.common.rest.agent.ActionResult;
+import org.apache.ambari.common.rest.agent.*;
@Provider
public class AgentJAXBContextResolver implements ContextResolver<JAXBContext> {
- private JAXBContext context;
- private Set<Class<?>> types;
- private Class<?>[] classTypes = {
- Command.class,
- HeartBeat.class,
- ControllerResponse.class,
+ private final JAXBContext context;
+ private static final Class<?>[] types = {
+ Action.class,
ActionResult.class,
- Action.class };
- protected Set<String> jsonArray = new HashSet<String>() {
- {
- add("actionResults");
- add("serversStatus");
- add("installedRoleStates");
- }
- };
-
- public AgentJAXBContextResolver() throws Exception {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(JSONJAXBContext.JSON_NOTATION, JSONJAXBContext.JSONNotation.MAPPED);
- props.put(JSONJAXBContext.JSON_ROOT_UNWRAPPING, Boolean.TRUE);
- props.put(JSONJAXBContext.JSON_ARRAYS, jsonArray);
- this.types = new HashSet<Class<?>>(Arrays.asList(classTypes));
- this.context = new JSONJAXBContext(classTypes, props);
+ ActionResults.class,
+ AgentRoleState.class,
+ Command.class,
+ CommandResult.class,
+ ConfigFile.class,
+ ControllerResponse.class,
+ HardwareProfile.class,
+ HeartBeat.class
+ };
+
+ public AgentJAXBContextResolver() throws JAXBException {
+ this.context = new JSONJAXBContext(JSONConfiguration.natural().build(),
+ types);
}
public JAXBContext getContext(Class<?> objectType) {
Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java?rev=1213977&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java Tue Dec 13 23:06:51 2011
@@ -0,0 +1,66 @@
+/*
+ * 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.ambari.controller.rest.resources;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.apache.ambari.common.rest.entities.*;
+
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.api.json.JSONJAXBContext;
+
+@Provider
+public class ContextProvider implements ContextResolver<JAXBContext> {
+
+ private final JAXBContext context;
+ private Class<?>[] types = { ClusterDefinition.class,
+ ClusterInformation.class,
+ ClusterState.class,
+ Component.class,
+ ComponentDefinition.class,
+ Configuration.class,
+ ConfigurationCategory.class,
+ Node.class,
+ NodeAttributes.class,
+ NodeServer.class,
+ NodeState.class,
+ Property.class,
+ RepositoryKind.class,
+ Role.class,
+ RoleToNodes.class,
+ Stack.class,
+ StackInformation.class
+ };
+
+ public ContextProvider() throws JAXBException {
+ this.context = new JSONJAXBContext(JSONConfiguration.natural().build(),
+ types);
+ }
+
+ public JAXBContext getContext(Class<?> objectType) {
+ for (Class<?> type : types) {
+ if (type.equals(objectType))
+ return context;
+ }
+ return null;
+ }
+}
\ No newline at end of file
Modified: incubator/ambari/trunk/controller/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/resources/WEB-INF/web.xml?rev=1213977&r1=1213976&r2=1213977&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/resources/WEB-INF/web.xml (original)
+++ incubator/ambari/trunk/controller/src/main/resources/WEB-INF/web.xml Tue Dec 13 23:06:51 2011
@@ -33,7 +33,7 @@
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
- <param-value>org.apache.hms.controller.rest</param-value>
+ <param-value>org.apache.ambari.controller.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>