You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2014/01/10 10:09:26 UTC
git commit: adding instance notification client to Autoscaler
Updated Branches:
refs/heads/master a440e8dae -> 0e6cf66cc
adding instance notification client to Autoscaler
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/0e6cf66c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/0e6cf66c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/0e6cf66c
Branch: refs/heads/master
Commit: 0e6cf66cc0bc6bee0f28d7a0f35adb80cc995358
Parents: a440e8d
Author: rekathiru <rt...@gmail.com>
Authored: Fri Jan 10 14:39:35 2014 +0530
Committer: rekathiru <rt...@gmail.com>
Committed: Fri Jan 10 14:39:35 2014 +0530
----------------------------------------------------------------------
.../org.apache.stratos.autoscaler/pom.xml | 7 ++
.../apache/stratos/autoscaler/Constants.java | 9 +++
.../controller/InstanceNotificationClient.java | 71 ++++++++++++++++++++
3 files changed, 87 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0e6cf66c/components/org.apache.stratos.autoscaler/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml
index 92798b0..f7f8b31 100644
--- a/components/org.apache.stratos.autoscaler/pom.xml
+++ b/components/org.apache.stratos.autoscaler/pom.xml
@@ -165,6 +165,13 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.manager.cleanup.notification.stub</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0e6cf66c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
index f6899df..ae351a7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
@@ -17,6 +17,15 @@ public class Constants {
public static final String CLOUD_CONTROLLER_SERVICE_SFX = "services/CloudControllerService";
public static final int CLOUD_CONTROLLER_DEFAULT_PORT = 9444;
+
+ public static final String STRATOS_MANAGER_SERVICE_SFX = "services/InstanceCleanupNotificationService";
+ public static final int STRATOS_MANAGER_DEFAULT_PORT = 9444;
+ public static final String STRATOS_MANAGER_HOSTNAME_ELEMENT = "stratos.manager.hostname";
+ public static final String STRATOS_MANAGER_DEFAULT_PORT_ELEMENT = "stratos.manager.port";
+
+
+
+
// partition properties
public static final String REGION_PROPERTY = "region";
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0e6cf66c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/InstanceNotificationClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/InstanceNotificationClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/InstanceNotificationClient.java
new file mode 100644
index 0000000..7977f4b
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/InstanceNotificationClient.java
@@ -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. TcSee the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.client.cloud.controller;
+
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.Constants;
+import org.apache.stratos.autoscaler.util.ConfUtil;
+import org.apache.stratos.manager.cleanup.notification.stub.*;
+
+import java.rmi.RemoteException;
+
+public class InstanceNotificationClient {
+ private static final Log log = LogFactory.getLog(CloudControllerClient.class);
+ private static InstanceCleanupNotificationServiceStub stub;
+
+ /* An instance of a InstanceNotificationClient is created when the class is loaded.
+ * Since the class is loaded only once, it is guaranteed that an object of
+ * InstanceNotificationClient is created only once. Hence it is singleton.
+ */
+ private static class InstanceHolder {
+ private static final InstanceNotificationClient INSTANCE = new InstanceNotificationClient();
+ }
+
+ public static InstanceNotificationClient getInstance() {
+ return InstanceHolder.INSTANCE;
+ }
+
+ private InstanceNotificationClient(){
+ try {
+ XMLConfiguration conf = ConfUtil.getInstance().getConfiguration();
+ int port = conf.getInt(Constants.STRATOS_MANAGER_DEFAULT_PORT_ELEMENT,
+ Constants.STRATOS_MANAGER_DEFAULT_PORT);
+ String hostname = conf.getString(Constants.STRATOS_MANAGER_HOSTNAME_ELEMENT, "localhost");
+ String epr = "https://" + hostname + ":" + port + "/" + Constants.STRATOS_MANAGER_SERVICE_SFX;
+ int cloudControllerClientTimeout = conf.getInt("autoscaler.cloudController.clientTimeout", 180000);
+ stub = new InstanceCleanupNotificationServiceStub(epr);
+ stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, cloudControllerClientTimeout);
+ stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, cloudControllerClientTimeout);
+ } catch (Exception e) {
+ log.error("Stub init error", e);
+ }
+ }
+
+ public void sendMemberCleanupEvent(String memberId) {
+ try {
+ stub.sendInstanceCleanupNotificationForMember(memberId);
+ } catch (RemoteException e) {
+ log.error("error while sending the cleanup notification event to SM", e);
+ }
+
+ }
+}