You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by hi...@apache.org on 2012/10/04 00:40:31 UTC

svn commit: r1393803 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-server/src/main/java/org/apache/ambari/server/controller/ ambari-server/src/main/java/org/apache/ambari/server/state/

Author: hitesh
Date: Wed Oct  3 22:40:31 2012
New Revision: 1393803

URL: http://svn.apache.org/viewvc?rev=1393803&view=rev
Log:
AMBARI-799. Prototype for management spi part 3. (hitesh)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java   (with props)
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java   (with props)
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.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=1393803&r1=1393802&r2=1393803&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Oct  3 22:40:31 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-799. Prototype for management spi part 3. (hitesh)
+
   AMBARI-797. Prototype for management spi interface continued. (hitesh)
 
   AMBARI-795. Fix failing tests for AgentResource and BootStrap. (mahadev)

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1393803&r1=1393802&r2=1393803&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Wed Oct  3 22:40:31 2012
@@ -1,3 +1,21 @@
+/**
+ * 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.HashMap;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java?rev=1393803&r1=1393802&r2=1393803&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java Wed Oct  3 22:40:31 2012
@@ -1,5 +1,67 @@
+/**
+ * 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 java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a single instance of a 'Config Type'
+ */
 public interface Config {
 
+  /**
+   * @return Config Type
+   */
+  public String getType();
+
+  /**
+   * @return Version Tag this config instance is mapped to
+   */
+  public String getVersionTag();
+
+  /**
+   * @return Properties that define this config instance
+   */
+  public Map<String, String> getProperties();
+
+  /**
+   * Change the version tag
+   * @param versionTag
+   */
+  public void setVersionTag(String versionTag);
+
+  /**
+   * Replace properties with new provided set
+   * @param properties Property Map to replace existing one
+   */
+  public void setProperties(Map<String, String> properties);
+
+  /**
+   * Update provided properties' values.
+   * @param properties Property Map with updated values
+   */
+  public void updateProperties(Map<String, String> properties);
+
+  /**
+   * Delete certain properties
+   * @param properties Property keys to be deleted
+   */
+  public void deleteProperties(List<String> properties);
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java?rev=1393803&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java Wed Oct  3 22:40:31 2012
@@ -0,0 +1,84 @@
+/**
+ * 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 java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ConfigImpl implements Config {
+  
+  private final String type;
+  
+  private String versionTag;
+  
+  private Map<String, String> properties;
+
+  public ConfigImpl(String type, String versionTag,
+      Map<String, String> properties) {
+    this.type = type;
+    this.versionTag = versionTag;
+    this.properties = properties;
+  }
+  
+  public ConfigImpl(String type, String versionTag) {
+    this(type, versionTag, new HashMap<String, String>());
+  }
+  
+  @Override
+  public String getType() {
+    return type;
+  }
+
+  @Override
+  public synchronized String getVersionTag() {
+    return versionTag;
+  }
+
+  @Override
+  public synchronized Map<String, String> getProperties() {
+    return Collections.unmodifiableMap(properties);
+  }
+
+  @Override
+  public synchronized void setVersionTag(String versionTag) {
+    this.versionTag = versionTag;
+  }
+
+  @Override
+  public synchronized void setProperties(Map<String, String> properties) {
+    this.properties = properties;
+  }
+
+  @Override
+  public synchronized void updateProperties(Map<String, String> properties) {
+    this.properties.putAll(properties);
+  }
+
+  @Override
+  public synchronized void deleteProperties(List<String> properties) {
+    for (String key : properties) {
+      this.properties.remove(key);
+    }
+  }
+  
+  
+
+}

Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java?rev=1393803&r1=1393802&r2=1393803&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java Wed Oct  3 22:40:31 2012
@@ -1,8 +1,25 @@
+/**
+ * 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 java.util.Map;
 
-
 public interface Service {
 
   public String getName();
@@ -11,15 +28,19 @@ public interface Service {
   
   public long getCurrentHostComponentMappingVersion();
 
+  public void setCurrentHostComponentMappingVersion(long version);
+
   public Map<String, ServiceComponent> getServiceComponents();
-    
-  public State getState();
+
+  public void addServiceComponents(Map<String, ServiceComponent> components);
+
+  public DeployState getState();
   
-  public void setState(State state);
+  public void setState(DeployState state);
 
-  public Config getConfig();
+  public Map<String, Config> getConfigs();
 
-  public void setConfig(Config config);
+  public void updateConfigs(Map<String, Config> configs);
   
   public StackVersion getStackVersion();
   

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java?rev=1393803&r1=1393802&r2=1393803&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java Wed Oct  3 22:40:31 2012
@@ -1,3 +1,21 @@
+/**
+ * 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 java.util.Map;
@@ -12,18 +30,20 @@ public interface ServiceComponent {
 
   public long getClusterId();
   
-  public State getState();
+  public DeployState getState();
   
-  public void setState(State state);
+  public void setState(DeployState state);
 
-  public Config getConfig();
+  public Map<String, Config> getConfigs();
 
-  public void setConfig(Config config);
+  public void updateConfigs(Map<String, Config> configs);
   
   public StackVersion getStackVersion();
   
   public void setStackVersion(StackVersion stackVersion);
-
+  
   public Map<String, ServiceComponentHost> getServiceComponentHosts();
   
+  public void addServiceComponentHosts(Map<String, ServiceComponentHost>
+      hostComponents);
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java?rev=1393803&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java Wed Oct  3 22:40:31 2012
@@ -0,0 +1,117 @@
+/**
+ * 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 java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHost;
+
+public class ServiceComponentImpl implements ServiceComponent {
+
+  private final Service service;
+  
+  private final String componentName;
+  
+  private DeployState state;
+  
+  private Map<String, Config> configs;
+
+  private Map<String, ServiceComponentHost> hostComponents;
+  
+  private StackVersion stackVersion;
+
+  private void init() {
+    // TODO
+    // initialize from DB 
+  }
+  
+  public ServiceComponentImpl(Service service,
+      String componentName, DeployState state, Map<String, Config> configs) {
+    this.service = service;
+    this.componentName = componentName;
+    this.state = state;
+    if (configs != null) {
+      this.configs = configs;
+    } else {
+      this.configs = new HashMap<String, Config>();
+    }
+    this.hostComponents = new HashMap<String, ServiceComponentHost>();
+    init();
+  }
+  
+  @Override
+  public synchronized String getName() {
+    return componentName;
+  }
+
+  @Override
+  public synchronized String getServiceName() {
+    return service.getName();
+  }
+
+  @Override
+  public synchronized long getClusterId() {
+    return this.service.getClusterId();
+  }
+
+  @Override
+  public synchronized DeployState getState() {
+    return state;
+  }
+
+  @Override
+  public synchronized void setState(DeployState state) {
+    this.state = state;
+  }
+
+  @Override
+  public synchronized Map<String, Config> getConfigs() {
+    return Collections.unmodifiableMap(configs);
+  }
+
+  @Override
+  public synchronized void updateConfigs(Map<String, Config> configs) {
+    this.configs = configs;
+  }
+
+  @Override
+  public synchronized StackVersion getStackVersion() {
+    return stackVersion;
+  }
+
+  @Override
+  public synchronized void setStackVersion(StackVersion stackVersion) {
+    this.stackVersion = stackVersion;
+  }
+
+  @Override
+  public synchronized Map<String, ServiceComponentHost>
+      getServiceComponentHosts() {
+    return Collections.unmodifiableMap(hostComponents);
+  }
+
+  @Override
+  public synchronized void addServiceComponentHosts(
+      Map<String, ServiceComponentHost> hostComponents) {
+    this.hostComponents.putAll(hostComponents);
+  }
+
+}

Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java?rev=1393803&r1=1393802&r2=1393803&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java Wed Oct  3 22:40:31 2012
@@ -1,5 +1,24 @@
+/**
+ * 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 java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -12,6 +31,7 @@ public class ServiceImpl implements Serv
   private DeployState state;
   private Map<String, Config> configs;
   private Map<String, ServiceComponent> components;
+  private StackVersion stackVersion;
   
   private void init() {
     // TODO
@@ -52,51 +72,55 @@ public class ServiceImpl implements Serv
   }
 
   @Override
-  public long getCurrentHostComponentMappingVersion() {
+  public synchronized long getCurrentHostComponentMappingVersion() {
     // TODO Auto-generated method stub
     return 0;
   }
 
   @Override
-  public Map<String, ServiceComponent> getServiceComponents() {
-    // TODO Auto-generated method stub
-    return null;
+  public synchronized Map<String, ServiceComponent> getServiceComponents() {
+    return Collections.unmodifiableMap(components);
   }
 
   @Override
-  public State getState() {
-    // TODO Auto-generated method stub
-    return null;
+  public synchronized DeployState getState() {
+    return state;
   }
 
   @Override
-  public void setState(State state) {
-    // TODO Auto-generated method stub
-
+  public synchronized void setState(DeployState state) {
+    this.state = state;
   }
 
   @Override
-  public Config getConfig() {
-    // TODO Auto-generated method stub
-    return null;
+  public synchronized StackVersion getStackVersion() {
+    return stackVersion;
   }
 
   @Override
-  public void setConfig(Config config) {
-    // TODO Auto-generated method stub
+  public synchronized void setStackVersion(StackVersion stackVersion) {
+    this.stackVersion = stackVersion;
+  }
 
+  @Override
+  public synchronized Map<String, Config> getConfigs() {
+    return Collections.unmodifiableMap(configs);
   }
 
   @Override
-  public StackVersion getStackVersion() {
-    // TODO Auto-generated method stub
-    return null;
+  public synchronized void updateConfigs(Map<String, Config> configs) {
+    this.configs.putAll(configs);
   }
 
   @Override
-  public void setStackVersion(StackVersion stackVersion) {
-    // TODO Auto-generated method stub
+  public synchronized void setCurrentHostComponentMappingVersion(long version) {
+    // TODO Auto-generated method stub    
+  }
 
+  @Override
+  public synchronized void addServiceComponents(
+      Map<String, ServiceComponent> components) {
+    this.components.putAll(components);
   }
 
 }