You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/03/04 20:16:30 UTC
svn commit: r1452457 [2/3] - in /incubator/ambari/trunk: ./
ambari-server/src/main/java/org/apache/ambari/server/
ambari-server/src/main/java/org/apache/ambari/server/api/resources/
ambari-server/src/main/java/org/apache/ambari/server/api/services/ amb...
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackResponse.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackResponse.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackResponse.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,57 @@
+/**
+ * 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.controller;
+
+
+public class StackResponse {
+
+ private String stackName;
+
+ public StackResponse(String stackName) {
+ setStackName(stackName);
+ }
+
+ public String getStackName() {
+ return stackName;
+ }
+
+ public void setStackName(String stackName) {
+ this.stackName = stackName;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = 31 + getStackName().hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof StackResponse)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ StackResponse stackResponse = (StackResponse) obj;
+ return getStackName().equals(stackResponse.getStackName());
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentRequest.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentRequest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentRequest.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,40 @@
+/**
+ * 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.controller;
+
+public class StackServiceComponentRequest extends StackServiceRequest {
+
+ private String componentName;
+
+ public StackServiceComponentRequest(String stackName, String stackVersion,
+ String serviceName, String componentName) {
+ super(stackName, stackVersion, serviceName);
+ setComponentName(componentName);
+ }
+
+ public String getComponentName() {
+ return componentName;
+ }
+
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,71 @@
+/**
+ * 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.controller;
+
+public class StackServiceComponentResponse {
+
+ private String componentName;
+
+ private String componentCategory;
+
+ private boolean isClient;
+
+ private boolean isMaster;
+
+ public StackServiceComponentResponse(String componentName, String componentCategory,
+ boolean isClient, boolean isMaster) {
+ setComponentName(componentName);
+ setComponentCategory(componentCategory);
+ setClient(isClient);
+ setMaster(isMaster);
+ }
+
+ public String getComponentName() {
+ return componentName;
+ }
+
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ public String getComponentCategory() {
+ return componentCategory;
+ }
+
+ public void setComponentCategory(String componentCategory) {
+ this.componentCategory = componentCategory;
+ }
+
+ public boolean isClient() {
+ return isClient;
+ }
+
+ public void setClient(boolean isClient) {
+ this.isClient = isClient;
+ }
+
+ public boolean isMaster() {
+ return isMaster;
+ }
+
+ public void setMaster(boolean isMaster) {
+ this.isMaster = isMaster;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceRequest.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceRequest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceRequest.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,42 @@
+/**
+ * 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.controller;
+
+public class StackServiceRequest extends StackVersionRequest {
+
+ private String serviceName;
+
+ public StackServiceRequest(String stackName, String stackVersion,
+ String serviceName) {
+ super(stackName, stackVersion);
+
+ this.setServiceName(serviceName);
+
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,70 @@
+/**
+ * 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.controller;
+
+public class StackServiceResponse {
+
+ private String serviceName;
+
+ private String userName;
+
+ private String comments;
+
+ private String serviceVersion;
+
+ public StackServiceResponse(String serviceName, String userName, String comments, String serviceVersion) {
+ setServiceName(serviceName);
+ setUserName(userName);
+ setComments(comments);
+ setServiceVersion(serviceVersion);
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getComments() {
+ return comments;
+ }
+
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+
+ public String getServiceVersion() {
+ return serviceVersion;
+ }
+
+ public void setServiceVersion(String serviceVersion) {
+ this.serviceVersion = serviceVersion;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionRequest.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionRequest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionRequest.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,40 @@
+/**
+ * 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.controller;
+
+
+public class StackVersionRequest extends StackRequest {
+
+ public StackVersionRequest(String stackName, String stackVersion) {
+ super(stackName);
+ setStackVersion(stackVersion);
+ }
+
+ public String getStackVersion() {
+ return stackVersion;
+ }
+
+ public void setStackVersion(String stackVersion) {
+ this.stackVersion = stackVersion;
+ }
+
+ private String stackVersion;
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,49 @@
+/**
+ * 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.controller;
+
+import java.util.List;
+
+import org.apache.ambari.server.state.RepositoryInfo;
+
+public class StackVersionResponse {
+
+ private String stackVersion;
+ private List<RepositoryInfo> repositories;
+
+ public StackVersionResponse(String stackVersion) {
+ setStackVersion(stackVersion);
+ }
+
+ public String getStackVersion() {
+ return stackVersion;
+ }
+
+ public void setStackVersion(String stackVersion) {
+ this.stackVersion = stackVersion;
+ }
+
+ public List<RepositoryInfo> getRepositories() {
+ return repositories;
+ }
+
+ public void setRepositories(List<RepositoryInfo> repositories) {
+ this.repositories = repositories;
+ }
+}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -352,6 +352,20 @@ public abstract class AbstractResourcePr
return new TaskResourceProvider(propertyIds, keyPropertyIds, managementController);
case User:
return new UserResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case Stack:
+ return new StackResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case StackVersion:
+ return new StackVersionResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case StackService:
+ return new StackServiceResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case StackServiceComponent:
+ return new StackServiceComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case StackConfiguration:
+ return new StackConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case OperatingSystem:
+ return new OperatingSystemResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case Repository:
+ return new RepositoryResourceProvider(propertyIds, keyPropertyIds, managementController);
default:
throw new IllegalArgumentException("Unknown type " + type);
}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,110 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.OperatingSystemRequest;
+import org.apache.ambari.server.controller.OperatingSystemResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+public class OperatingSystemResourceProvider extends ReadOnlyResourceProvider {
+
+ public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("OperatingSystems", "stack_name");
+
+ private static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("OperatingSystems", "stack_version");
+
+ private static final String OS_TYPE_PROPERTY_ID = PropertyHelper
+ .getPropertyId("OperatingSystems", "os_type");
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
+ STACK_VERSION_PROPERTY_ID, OS_TYPE_PROPERTY_ID }));
+
+ protected OperatingSystemResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+ final OperatingSystemRequest operatingSystemRequest = getRequest(PredicateHelper
+ .getProperties(predicate));
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<OperatingSystemResponse> responses = getResources(new Command<Set<OperatingSystemResponse>>() {
+ @Override
+ public Set<OperatingSystemResponse> invoke() throws AmbariException {
+ return getManagementController().getStackOperatingSystems(
+ Collections.singleton(operatingSystemRequest));
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (OperatingSystemResponse response : responses) {
+ Resource resource = new ResourceImpl(Resource.Type.OperatingSystem);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ operatingSystemRequest.getStackName(), requestedIds);
+
+ setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+ operatingSystemRequest.getStackVersion(), requestedIds);
+
+ setResourceProperty(resource, OS_TYPE_PROPERTY_ID,
+ response.getOsType(), requestedIds);
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private OperatingSystemRequest getRequest(Map<String, Object> properties) {
+ return new OperatingSystemRequest((String) properties.get(STACK_NAME_PROPERTY_ID),
+ (String) properties.get(STACK_VERSION_PROPERTY_ID),
+ (String) properties.get(OS_TYPE_PROPERTY_ID));
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -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.controller.internal;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+
+public abstract class ReadOnlyResourceProvider extends AbstractResourceProvider {
+
+ private static final String READ_ONLY_MSG = "Read-only resource";
+
+ protected ReadOnlyResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+ @Override
+ public RequestStatus createResources(Request request) throws SystemException,
+ UnsupportedPropertyException, ResourceAlreadyExistsException,
+ NoSuchParentResourceException {
+ throw new SystemException(READ_ONLY_MSG, null);
+ }
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+ throw new SystemException(READ_ONLY_MSG, null);
+ }
+
+ @Override
+ public RequestStatus updateResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+ throw new SystemException(READ_ONLY_MSG, null);
+ }
+
+ @Override
+ public RequestStatus deleteResources(Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+ throw new SystemException(READ_ONLY_MSG, null);
+ }
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,142 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.RepositoryRequest;
+import org.apache.ambari.server.controller.RepositoryResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+public class RepositoryResourceProvider extends ReadOnlyResourceProvider {
+
+ public static final String REPOSITORY_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "repo_name");
+
+ private static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "stack_name");
+
+ private static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "stack_version");
+
+ private static final String OS_TYPE_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "os_type");
+
+ private static final String REPOSITORY_BASE_URL_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "base_url");
+
+ private static final String REPOSITORY_OS_TYPE_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "os_type");
+
+ private static final String REPO_ID_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "repo_id");
+
+ private static final String REPOSITORY_MIRRORS_LIST_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Repositories", "mirrors_list");;
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
+ STACK_VERSION_PROPERTY_ID, OS_TYPE_PROPERTY_ID,
+ REPO_ID_PROPERTY_ID }));
+
+ public RepositoryResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+
+ final RepositoryRequest repositoryRequest = getRequest(PredicateHelper
+ .getProperties(predicate));
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<RepositoryResponse> responses = getResources(new Command<Set<RepositoryResponse>>() {
+ @Override
+ public Set<RepositoryResponse> invoke() throws AmbariException {
+ return getManagementController().getRepositories(
+ Collections.singleton(repositoryRequest));
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (RepositoryResponse response : responses) {
+ Resource resource = new ResourceImpl(Resource.Type.Repository);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ repositoryRequest.getStackName(), requestedIds);
+
+ setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+ repositoryRequest.getStackVersion(), requestedIds);
+
+ setResourceProperty(resource, REPOSITORY_NAME_PROPERTY_ID,
+ response.getRepoName(), requestedIds);
+
+ setResourceProperty(resource, REPOSITORY_BASE_URL_PROPERTY_ID,
+ response.getBaseUrl(), requestedIds);
+
+ setResourceProperty(resource, REPOSITORY_OS_TYPE_PROPERTY_ID,
+ response.getOsType(), requestedIds);
+
+ setResourceProperty(resource, REPO_ID_PROPERTY_ID,
+ response.getRepoId(), requestedIds);
+
+ setResourceProperty(resource, REPOSITORY_MIRRORS_LIST_PROPERTY_ID,
+ response.getMirrorsList(), requestedIds);
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private RepositoryRequest getRequest(Map<String, Object> properties) {
+ return new RepositoryRequest(
+ (String) properties.get(STACK_NAME_PROPERTY_ID),
+ (String) properties.get(STACK_VERSION_PROPERTY_ID),
+ (String) properties.get(OS_TYPE_PROPERTY_ID),
+ (String) properties.get(REPO_ID_PROPERTY_ID)
+ );
+ }
+
+ @Override
+ public Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,139 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.StackConfigurationRequest;
+import org.apache.ambari.server.controller.StackConfigurationResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+public class StackConfigurationResourceProvider extends
+ ReadOnlyResourceProvider {
+
+ private static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurations", "stack_name");
+
+ private static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurations", "stack_version");
+
+ private static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurations", "service_name");
+
+ private static final String PROPERTY_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurations", "property_name");
+
+ private static final String PROPERTY_VALUE_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurations", "property_value");
+
+ private static final String PROPERTY_DESCRIPTION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurations", "property_description");
+
+ private static final String PROPERTY_FILE_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurations", "filename");
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
+ STACK_VERSION_PROPERTY_ID, SERVICE_NAME_PROPERTY_ID, PROPERTY_NAME_PROPERTY_ID }));
+
+ protected StackConfigurationResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+ final StackConfigurationRequest stackConfigurationRequest = getRequest(PredicateHelper
+ .getProperties(predicate));
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<StackConfigurationResponse> responses = getResources(new Command<Set<StackConfigurationResponse>>() {
+ @Override
+ public Set<StackConfigurationResponse> invoke() throws AmbariException {
+ return getManagementController().getStackConfigurations(
+ Collections.singleton(stackConfigurationRequest));
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (StackConfigurationResponse response : responses) {
+ Resource resource = new ResourceImpl(Resource.Type.StackConfiguration);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ stackConfigurationRequest.getStackName(), requestedIds);
+
+ setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+ stackConfigurationRequest.getStackVersion(), requestedIds);
+
+ setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
+ stackConfigurationRequest.getServiceName(), requestedIds);
+
+ setResourceProperty(resource, PROPERTY_NAME_PROPERTY_ID,
+ response.getPropertyName(), requestedIds);
+
+ setResourceProperty(resource, PROPERTY_VALUE_PROPERTY_ID,
+ response.getPropertyValue(), requestedIds);
+
+ setResourceProperty(resource, PROPERTY_DESCRIPTION_PROPERTY_ID,
+ response.getPropertyDescription(), requestedIds);
+
+ setResourceProperty(resource, PROPERTY_FILE_NAME_PROPERTY_ID,
+ response.getFileName(), requestedIds);
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private StackConfigurationRequest getRequest(Map<String, Object> properties) {
+ return new StackConfigurationRequest(
+ (String) properties.get(STACK_NAME_PROPERTY_ID),
+ (String) properties.get(STACK_VERSION_PROPERTY_ID),
+ (String) properties.get(SERVICE_NAME_PROPERTY_ID),
+ (String) properties.get(PROPERTY_NAME_PROPERTY_ID));
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,98 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.StackRequest;
+import org.apache.ambari.server.controller.StackResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+public class StackResourceProvider extends ReadOnlyResourceProvider {
+
+ public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Stacks", "stack_name");
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID }));
+
+ protected StackResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+
+ final StackRequest stackRequest = getRequest(PredicateHelper
+ .getProperties(predicate));
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<StackResponse> responses = getResources(new Command<Set<StackResponse>>() {
+ @Override
+ public Set<StackResponse> invoke() throws AmbariException {
+ return getManagementController().getStacks(
+ Collections.singleton(stackRequest));
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (StackResponse response : responses) {
+ Resource resource = new ResourceImpl(Resource.Type.Stack);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ response.getStackName(), requestedIds);
+
+ resource.setProperty(STACK_NAME_PROPERTY_ID, response.getStackName());
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private StackRequest getRequest(Map<String, Object> properties) {
+ return new StackRequest((String) properties.get(STACK_NAME_PROPERTY_ID));
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,134 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.StackServiceComponentRequest;
+import org.apache.ambari.server.controller.StackServiceComponentResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+public class StackServiceComponentResourceProvider extends
+ ReadOnlyResourceProvider {
+
+ protected static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "stack_name");
+ protected static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "stack_version");
+ protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "service_name");
+ protected static final String COMPONENT_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "component_name");
+ protected static final String COMPONENT_CATEGORY_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "component_category");
+ protected static final String IS_CLIENT_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "is_client");
+ protected static final String IS_MASTER_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "is_master");
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
+ STACK_VERSION_PROPERTY_ID, SERVICE_NAME_PROPERTY_ID,
+ COMPONENT_NAME_PROPERTY_ID }));
+
+ protected StackServiceComponentResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+ final StackServiceComponentRequest stackRequest = getRequest(PredicateHelper
+ .getProperties(predicate));
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<StackServiceComponentResponse> responses = getResources(new Command<Set<StackServiceComponentResponse>>() {
+ @Override
+ public Set<StackServiceComponentResponse> invoke() throws AmbariException {
+ return getManagementController().getStackComponents(
+ Collections.singleton(stackRequest));
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (StackServiceComponentResponse response : responses) {
+ Resource resource = new ResourceImpl(Resource.Type.StackServiceComponent);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ stackRequest.getStackName(), requestedIds);
+
+ setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+ stackRequest.getStackVersion(), requestedIds);
+
+ setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
+ stackRequest.getServiceName(), requestedIds);
+
+ setResourceProperty(resource, COMPONENT_NAME_PROPERTY_ID,
+ response.getComponentName(), requestedIds);
+
+ setResourceProperty(resource, COMPONENT_CATEGORY_PROPERTY_ID,
+ response.getComponentCategory(), requestedIds);
+
+ setResourceProperty(resource, IS_CLIENT_PROPERTY_ID,
+ response.isClient(), requestedIds);
+
+ setResourceProperty(resource, IS_MASTER_PROPERTY_ID,
+ response.isMaster(), requestedIds);
+
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private StackServiceComponentRequest getRequest(Map<String, Object> properties) {
+ return new StackServiceComponentRequest(
+ (String) properties.get(STACK_NAME_PROPERTY_ID),
+ (String) properties.get(STACK_VERSION_PROPERTY_ID),
+ (String) properties.get(SERVICE_NAME_PROPERTY_ID),
+ (String) properties.get(COMPONENT_NAME_PROPERTY_ID));
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,131 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.StackServiceRequest;
+import org.apache.ambari.server.controller.StackServiceResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
+
+ protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "service_name");
+
+ public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "stack_name");
+
+ public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "stack_version");
+
+ private static final String USER_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "user_name");
+
+ private static final String COMMENTS_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "comments");
+
+ private static final String VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "service_version");;
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
+ STACK_VERSION_PROPERTY_ID, SERVICE_NAME_PROPERTY_ID }));
+
+ protected StackServiceResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+
+ final StackServiceRequest stackServiceRequest = getRequest(PredicateHelper
+ .getProperties(predicate));
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<StackServiceResponse> responses = getResources(new Command<Set<StackServiceResponse>>() {
+ @Override
+ public Set<StackServiceResponse> invoke() throws AmbariException {
+ return getManagementController().getStackServices(
+ Collections.singleton(stackServiceRequest));
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (StackServiceResponse response : responses) {
+ Resource resource = new ResourceImpl(Resource.Type.StackService);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ stackServiceRequest.getStackName(), requestedIds);
+
+ setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+ stackServiceRequest.getStackVersion(), requestedIds);
+
+ setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
+ response.getServiceName(), requestedIds);
+
+ setResourceProperty(resource, USER_NAME_PROPERTY_ID,
+ response.getUserName(), requestedIds);
+
+ setResourceProperty(resource, COMMENTS_PROPERTY_ID,
+ response.getComments(), requestedIds);
+
+ setResourceProperty(resource, VERSION_PROPERTY_ID,
+ response.getServiceVersion(), requestedIds);
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private StackServiceRequest getRequest(Map<String, Object> properties) {
+ return new StackServiceRequest(
+ (String) properties.get(STACK_NAME_PROPERTY_ID),
+ (String) properties.get(STACK_VERSION_PROPERTY_ID),
+ (String) properties.get(SERVICE_NAME_PROPERTY_ID));
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+
+}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java Mon Mar 4 19:16:28 2013
@@ -0,0 +1,107 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.StackVersionRequest;
+import org.apache.ambari.server.controller.StackVersionResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+public class StackVersionResourceProvider extends ReadOnlyResourceProvider {
+
+ protected StackVersionResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+ public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Versions", "stack_version");
+
+ private static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Versions", "stack_name");;
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
+ STACK_VERSION_PROPERTY_ID }));
+
+
+ @Override
+ public Set<Resource> getResources(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+
+ final StackVersionRequest stackVersionRequest = getRequest(PredicateHelper
+ .getProperties(predicate));
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<StackVersionResponse> responses = getResources(new Command<Set<StackVersionResponse>>() {
+ @Override
+ public Set<StackVersionResponse> invoke() throws AmbariException {
+ return getManagementController().getStackVersions(
+ Collections.singleton(stackVersionRequest));
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (StackVersionResponse response : responses) {
+ Resource resource = new ResourceImpl(Resource.Type.StackVersion);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ stackVersionRequest.getStackName(), requestedIds);
+
+ setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+ response.getStackVersion(), requestedIds);
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private StackVersionRequest getRequest(Map<String, Object> properties) {
+ return new StackVersionRequest(
+ (String) properties.get(STACK_NAME_PROPERTY_ID),
+ (String) properties.get(STACK_VERSION_PROPERTY_ID));
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+
+}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java Mon Mar 4 19:16:28 2013
@@ -89,6 +89,13 @@ public interface Resource {
Action,
Request,
Task,
- User
+ User,
+ Stack,
+ StackVersion,
+ OperatingSystem,
+ Repository,
+ StackService,
+ StackConfiguration,
+ StackServiceComponent
}
}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java Mon Mar 4 19:16:28 2013
@@ -18,6 +18,8 @@
package org.apache.ambari.server.state;
+import org.apache.ambari.server.controller.StackServiceComponentResponse;
+
public class ComponentInfo {
private String name;
private String category;
@@ -46,4 +48,8 @@ public class ComponentInfo {
return "MASTER".equals(category);
}
+ public StackServiceComponentResponse convertToResponse() {
+ return new StackServiceComponentResponse(getName(), getCategory(), isClient(), isMaster());
+ }
+
}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/OperatingSystemInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/OperatingSystemInfo.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/OperatingSystemInfo.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/OperatingSystemInfo.java Mon Mar 4 19:16:28 2013
@@ -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.state;
+
+import org.apache.ambari.server.controller.OperatingSystemResponse;
+
+
+public class OperatingSystemInfo {
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((osType == null) ? 0 : osType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ OperatingSystemInfo other = (OperatingSystemInfo) obj;
+ if (osType == null) {
+ if (other.osType != null)
+ return false;
+ } else if (!osType.equals(other.osType))
+ return false;
+ return true;
+ }
+
+ private String osType;
+
+ public OperatingSystemInfo(String osType) {
+ setOsType(osType);
+ }
+
+ public String getOsType() {
+ return osType;
+ }
+
+ public void setOsType(String osType) {
+ this.osType = osType;
+ }
+
+ public OperatingSystemResponse convertToResponse()
+ {
+ return new OperatingSystemResponse(getOsType());
+ }
+
+
+
+}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java Mon Mar 4 19:16:28 2013
@@ -18,7 +18,11 @@
package org.apache.ambari.server.state;
+import org.apache.ambari.server.controller.StackConfigurationResponse;
+
public class PropertyInfo {
+
+
private String name;
private String value;
private String description;
@@ -55,4 +59,53 @@ public class PropertyInfo {
public void setFilename(String filename) {
this.filename = filename;
}
+
+ public StackConfigurationResponse convertToResponse()
+ {
+ return new StackConfigurationResponse(getName(), getValue(), getDescription() , getFilename());
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((filename == null) ? 0 : filename.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PropertyInfo other = (PropertyInfo) obj;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (filename == null) {
+ if (other.filename != null)
+ return false;
+ } else if (!filename.equals(other.filename))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (value == null) {
+ if (other.value != null)
+ return false;
+ } else if (!value.equals(other.value))
+ return false;
+ return true;
+ }
}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java Mon Mar 4 19:16:28 2013
@@ -18,6 +18,8 @@
package org.apache.ambari.server.state;
+import org.apache.ambari.server.controller.RepositoryResponse;
+
public class RepositoryInfo {
private String baseUrl;
private String osType;
@@ -105,4 +107,10 @@ public class RepositoryInfo {
+ ", mirrorsList=" + mirrorsList
+ " ]";
}
+
+
+ public RepositoryResponse convertToResponse()
+ {
+ return new RepositoryResponse(getBaseUrl(), getOsType(), getRepoId(), getRepoName(), getMirrorsList());
+ }
}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java Mon Mar 4 19:16:28 2013
@@ -80,7 +80,7 @@ public class ServiceComponentImpl implem
@AssistedInject
public ServiceComponentImpl(@Assisted Service service,
- @Assisted String componentName, Injector injector) {
+ @Assisted String componentName, Injector injector) throws AmbariException {
injector.injectMembers(this);
this.service = service;
this.desiredStateEntity = new ServiceComponentDesiredStateEntity();
@@ -112,7 +112,7 @@ public class ServiceComponentImpl implem
@AssistedInject
public ServiceComponentImpl(@Assisted Service service,
@Assisted ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity,
- Injector injector) {
+ Injector injector) throws AmbariException {
injector.injectMembers(this);
this.service = service;
this.desiredStateEntity = serviceComponentDesiredStateEntity;
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java Mon Mar 4 19:16:28 2013
@@ -78,7 +78,7 @@ public class ServiceImpl implements Serv
@AssistedInject
public ServiceImpl(@Assisted Cluster cluster, @Assisted String serviceName,
- Injector injector) {
+ Injector injector) throws AmbariException {
injector.injectMembers(this);
serviceEntity = new ClusterServiceEntity();
serviceEntity.setServiceName(serviceName);
@@ -104,7 +104,7 @@ public class ServiceImpl implements Serv
@AssistedInject
public ServiceImpl(@Assisted Cluster cluster, @Assisted ClusterServiceEntity
- serviceEntity, Injector injector) {
+ serviceEntity, Injector injector) throws AmbariException {
injector.injectMembers(this);
this.serviceEntity = serviceEntity;
this.cluster = cluster;
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java Mon Mar 4 19:16:28 2013
@@ -21,6 +21,8 @@ package org.apache.ambari.server.state;
import java.util.ArrayList;
import java.util.List;
+import org.apache.ambari.server.controller.StackConfigurationResponse;
+import org.apache.ambari.server.controller.StackServiceResponse;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonFilter;
@@ -116,4 +118,9 @@ public class ServiceInfo {
return sb.toString();
}
+
+ public StackServiceResponse convertToResponse()
+ {
+ return new StackServiceResponse(getName(), getUser(), getComment(), getVersion());
+ }
}
Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Stack.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Stack.java?rev=1452457&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Stack.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Stack.java Mon Mar 4 19:16:28 2013
@@ -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.state;
+
+import org.apache.ambari.server.controller.StackResponse;
+
+public class Stack {
+
+ private String stackName;
+
+ public Stack(String stackName) {
+ setStackName(stackName);
+ }
+
+ public String getStackName() {
+ return stackName;
+ }
+
+ public void setStackName(String stackName) {
+ this.stackName = stackName;
+ }
+
+ @Override
+ public int hashCode() {
+ return stackName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+
+ if (obj == null)
+ return false;
+
+ if (!(obj instanceof Stack)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ Stack stack = (Stack) obj;
+ return getStackName().equals(stack.getStackName());
+ }
+
+
+ public StackResponse convertToResponse()
+ {
+ return new StackResponse(getStackName());
+ }
+}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java Mon Mar 4 19:16:28 2013
@@ -21,6 +21,8 @@ package org.apache.ambari.server.state;
import java.util.ArrayList;
import java.util.List;
+import org.apache.ambari.server.controller.StackVersionResponse;
+
public class StackInfo {
private String name;
private String version;
@@ -80,4 +82,29 @@ public class StackInfo {
return sb.toString();
}
+
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = 31 + name.hashCode() + version.hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof StackInfo)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ StackInfo stackInfo = (StackInfo) obj;
+ return getName().equals(stackInfo.getName()) && getVersion().equals(stackInfo.getVersion());
+ }
+
+ public StackVersionResponse convertToResponse() {
+
+ return new StackVersionResponse(getVersion());
+ }
}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java Mon Mar 4 19:16:28 2013
@@ -293,7 +293,7 @@ public class ClustersImpl implements Clu
}
}
- private boolean isOsSupportedByClusterStack(Cluster c, Host h) {
+ private boolean isOsSupportedByClusterStack(Cluster c, Host h) throws AmbariException {
Map<String, List<RepositoryInfo>> repos =
ambariMetaInfo.getRepository(c.getDesiredStackVersion().getStackName(),
c.getDesiredStackVersion().getStackVersion());
Modified: incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json (original)
+++ incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json Mon Mar 4 19:16:28 2013
@@ -42,5 +42,43 @@
},
"User":{
"User":"Users/user_name"
+ },
+ "Stack":{
+ "Stack":"Stacks/stack_name"
+ },
+ "StackVersion":{
+ "Stack":"Versions/stack_name",
+ "StackVersion":"Versions/stack_version"
+ },
+
+ "OperatingSystem":{
+ "Stack":"OperatingSystems/stack_name",
+ "StackVersion":"OperatingSystems/stack_version",
+ "OperatingSystem":"OperatingSystems/os_type"
+ },
+
+ "Repository":{
+ "Stack":"Repositories/stack_name",
+ "StackVersion":"Repositories/stack_version",
+ "OperatingSystem":"Repositories/os_type",
+ "Repository":"Repositories/repo_id"
+ },
+
+ "StackService":{
+ "Stack":"StackServices/stack_name",
+ "StackVersion":"StackServices/stack_version",
+ "StackService":"StackServices/service_name"
+ },
+ "StackConfiguration":{
+ "Stack":"StackConfigurations/stack_name",
+ "StackVersion":"StackConfigurations/stack_version",
+ "StackService":"StackConfigurations/service_name",
+ "StackConfiguration":"StackConfigurations/property_name"
+ },
+ "StackServiceComponent":{
+ "Stack":"StackServiceComponents/stack_name",
+ "StackVersion":"StackServiceComponents/stack_version",
+ "StackService":"StackServiceComponents/service_name",
+ "StackServiceComponent":"StackServiceComponents/component_name"
}
}
Modified: incubator/ambari/trunk/ambari-server/src/main/resources/properties.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/properties.json?rev=1452457&r1=1452456&r2=1452457&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/resources/properties.json (original)
+++ incubator/ambari/trunk/ambari-server/src/main/resources/properties.json Mon Mar 4 19:16:28 2013
@@ -98,5 +98,63 @@
"Users/old_password",
"Users/ldap_user",
"_"
+ ],
+ "Stack":[
+ "Stacks/stack_name",
+ "_"
+ ],
+ "StackVersion":[
+ "Versions/stack_name",
+ "Versions/stack_version",
+ "_"
+ ],
+
+
+ "OperatingSystem":[
+ "OperatingSystems/stack_name",
+ "OperatingSystems/stack_version",
+ "OperatingSystems/os_type",
+ "_"
+ ],
+
+ "Repository":[
+ "Repositories/stack_name",
+ "Repositories/stack_version",
+ "Repositories/os_type",
+ "Repositories/base_url",
+ "Repositories/repo_id",
+ "Repositories/repo_name",
+ "Repositories/mirrors_list",
+ "_"
+ ],
+ "StackService":[
+ "StackServices/stack_name",
+ "StackServices/stack_version",
+ "StackServices/service_name",
+ "StackServices/user_name",
+ "StackServices/comments",
+ "StackServices/service_version",
+ "_"
+ ],
+ "StackConfiguration":[
+ "StackConfigurations/stack_name",
+ "StackConfigurations/stack_version",
+ "StackConfigurations/service_name",
+ "StackConfigurations/property_name",
+ "StackConfigurations/property_value",
+ "StackConfigurations/property_description",
+ "StackConfigurations/filename",
+ "_"
+ ],
+ "StackServiceComponent":[
+ "StackServiceComponents/stack_name",
+ "StackServiceComponents/stack_version",
+ "StackServiceComponents/service_name",
+ "StackServiceComponents/component_name",
+ "StackServiceComponents/component_category",
+ "StackServiceComponents/is_client",
+ "StackServiceComponents/is_master",
+ "_"
]
+ }
}