You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/09/14 09:04:05 UTC
svn commit: r1384660 - in /incubator/ambari/branches/AMBARI-666: ./
ambari-server/src/main/java/org/apache/ambari/server/api/rest/
ambari-server/src/main/java/org/apache/ambari/server/bootstrap/
ambari-server/src/test/java/org/apache/ambari/server/agent/
Author: mahadev
Date: Fri Sep 14 07:04:05 2012
New Revision: 1384660
URL: http://svn.apache.org/viewvc?rev=1384660&view=rev
Log:
AMBARI-733. Add Jersey Resource for BootStrapping and JAXB elements for API entities. (mahadev)
Added:
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/BootStrapResource.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSHostStatus.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapPostStatus.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapStatus.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java
Modified:
incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1384660&r1=1384659&r2=1384660&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Fri Sep 14 07:04:05 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
NEW FEATURES
+ AMBARI-733. Add Jersey Resource for BootStrapping and JAXB elements for API
+ entities. (mahadev)
+
AMBARI-730. Add unit tests for jersey apis on the server. (mahadev)
AMBARI-725. Add commandstatus/result/error objects into the rest API between
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/BootStrapResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/BootStrapResource.java?rev=1384660&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/BootStrapResource.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/BootStrapResource.java Fri Sep 14 07:04:05 2012
@@ -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.server.api.rest;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.ambari.server.bootstrap.BootStrapPostStatus;
+import org.apache.ambari.server.bootstrap.BootStrapStatus;
+import org.apache.ambari.server.bootstrap.SshHostInfo;
+
+@Path("/bootstrap")
+public class BootStrapResource {
+
+ /**
+ * Run bootstrap on a list of hosts.
+ * @response.representation.200.doc
+ *
+ * @response.representation.200.mediaType application/json
+ * @response.representation.406.doc Error in format
+ * @response.representation.408.doc Request Timed out
+ * @throws Exception
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public BootStrapPostStatus bootStrap(SshHostInfo sshInfo) {
+
+ return new BootStrapPostStatus();
+ }
+
+ /**
+ * Current BootStrap Information thats running.
+ * @response.representation.200.doc
+ *
+ * @response.representation.200.mediaType application/json
+ * @response.representation.406.doc Error in format
+ * @response.representation.408.doc Request Timed out
+ * @throws Exception
+ */
+ @GET
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public BootStrapStatus getBootStrapStatus() {
+ return new BootStrapStatus();
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSHostStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSHostStatus.java?rev=1384660&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSHostStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSHostStatus.java Fri Sep 14 07:04:05 2012
@@ -0,0 +1,64 @@
+/**
+ * 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.server.bootstrap;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * BootStrap Status for a host.
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class BSHostStatus {
+ @XmlElement
+ private String status;
+ @XmlElement
+ private String hostName;
+ @XmlElement
+ private String log;
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getHostName() {
+ return this.hostName;
+ }
+
+ public String getLog() {
+ return this.log;
+ }
+
+ public void setLog(String log) {
+ this.log = log;
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapPostStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapPostStatus.java?rev=1384660&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapPostStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapPostStatus.java Fri Sep 14 07:04:05 2012
@@ -0,0 +1,73 @@
+/**
+ * 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.server.bootstrap;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * Class captures immediate response to a bootstrap api call.
+ * If the api call is ok, the return should return that its ok.
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class BootStrapPostStatus {
+ @XmlType(name="status")
+ @XmlEnum
+ public enum BSPostStat {
+ OK,
+ ERROR
+ }
+
+ @XmlElement
+ private BSPostStat postStatus;
+ @XmlElement
+ private String log;
+ @XmlElement
+ private long requestId;
+
+ public long getRequestId() {
+ return this.requestId;
+ }
+
+ public void setRequestId(long requestId) {
+ this.requestId = requestId;
+ }
+
+ public BSPostStat getStatus() {
+ return this.postStatus;
+ }
+
+ public void setStatus(BSPostStat status) {
+ this.postStatus = status;
+ }
+
+ public String getLog() {
+ return this.log;
+ }
+
+ public void setLog(String log) {
+ this.log = log;
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapStatus.java?rev=1384660&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapStatus.java Fri Sep 14 07:04:05 2012
@@ -0,0 +1,68 @@
+/**
+ * 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.server.bootstrap;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * Status of a bootstrap operation. Operation is successful or error
+ * and explains all the info regarding the operation on each host.
+ *
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class BootStrapStatus {
+ @XmlType(name="status")
+ @XmlEnum
+ public enum BSStat {
+ OK,
+ ERROR
+ }
+
+ @XmlElement
+ private BSStat status;
+
+ @XmlElement
+ private List<BSHostStatus> hostsStatus;
+
+ public void setStatus(BSStat status) {
+ this.status = status;
+ }
+
+ public BSStat getStatus() {
+ return this.status;
+ }
+
+ public void setHostsStatus(List<BSHostStatus> hostsStatus) {
+ this.hostsStatus = hostsStatus;
+ }
+
+ public List<BSHostStatus> getHostsStatus() {
+ return this.hostsStatus;
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java?rev=1384660&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java Fri Sep 14 07:04:05 2012
@@ -0,0 +1,60 @@
+/**
+ * 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.server.bootstrap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * Information that the API needs to provide to run bootstrap on hosts.
+ *
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class SshHostInfo {
+
+ @XmlElement
+ private String sshKey;
+
+ @XmlElement
+ private List<String> hosts = new ArrayList<String>();
+
+ public String getSshKey() {
+ return sshKey;
+ }
+
+ public void setSshKey(String sshKey) {
+ this.sshKey = sshKey;
+ }
+
+ public void setHosts(List<String> hosts) {
+ this.hosts = hosts;
+ }
+
+ public List<String> getHosts() {
+ return this.hosts;
+ }
+}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java?rev=1384660&r1=1384659&r2=1384660&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java Fri Sep 14 07:04:05 2012
@@ -18,9 +18,7 @@
package org.apache.ambari.server.agent;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import javax.ws.rs.core.MediaType;