You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ma...@apache.org on 2014/03/13 15:36:02 UTC
[1/2] git commit: Refactor repository notification code
Repository: incubator-stratos
Updated Branches:
refs/heads/master 969ab39fe -> 30279d356
Refactor repository notification code
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/5c3712c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/5c3712c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/5c3712c7
Branch: refs/heads/master
Commit: 5c3712c7839b1c0fe07d3c2931f990d23a8765bb
Parents: add6e6d
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Thu Mar 13 20:05:13 2014 +0530
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Thu Mar 13 20:05:13 2014 +0530
----------------------------------------------------------------------
.../RepoNotificationServiceClient.java | 84 --------------------
.../repository/RepositoryNotification.java | 71 +++++++++++++++++
.../rest/endpoint/services/ServiceUtils.java | 17 +---
3 files changed, 74 insertions(+), 98 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5c3712c7/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepoNotificationServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepoNotificationServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepoNotificationServiceClient.java
deleted file mode 100644
index 0b0ea86..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepoNotificationServiceClient.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-* Copyright (c) 2005-2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. 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.stratos.manager.repository;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.publisher.InstanceNotificationPublisher;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.util.Set;
-
-public class RepoNotificationServiceClient {
-
- private static final Log log = LogFactory.getLog(RepoNotificationServiceClient.class);
- private static volatile RepoNotificationServiceClient serviceClient;
-
- public static RepoNotificationServiceClient getServiceClient() throws AxisFault {
- if (serviceClient == null) {
- synchronized (RepoNotificationServiceClient.class) {
- if (serviceClient == null) {
- serviceClient = new RepoNotificationServiceClient();
- }
- }
- }
- return serviceClient;
- }
-
- public void updateRepository(String url) {
-
- if ( StringUtils.isNotBlank(url)) {
-
- Set<CartridgeSubscription> cartridgeSubscriptions = new DataInsertionAndRetrievalManager().
- getCartridgeSubscriptionForRepository(url);
-
- if (cartridgeSubscriptions == null || cartridgeSubscriptions.isEmpty()) {
- // No subscriptions, return
- if (log.isDebugEnabled()) {
- log.debug("No subscription information found for repo url : " + url);
- }
-
- return;
- }
-
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
-
- if (cartridgeSubscription.getRepository() != null) {
- InstanceNotificationPublisher publisher = new InstanceNotificationPublisher();
- publisher.sendArtifactUpdateEvent(cartridgeSubscription.getRepository(), String.valueOf(cartridgeSubscription.getCluster().getId()),
- String.valueOf(cartridgeSubscription.getSubscriber().getTenantId()));
-
- if (log.isDebugEnabled()) {
- log.debug("Git pull request from " + cartridgeSubscription.getRepository() + "repository, for the tenant " +
- String.valueOf(cartridgeSubscription.getSubscriber().getTenantId()));
- }
-
- } else {
- if(log.isDebugEnabled()) {
- log.debug("No repository found for subscription with alias: " + cartridgeSubscription.getAlias() + ", type: " + cartridgeSubscription.getType()+
- ". Not sending the Artifact Updated event");
- }
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5c3712c7/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java
new file mode 100644
index 0000000..6b543d2
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2005-2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. 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.stratos.manager.repository;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.manager.publisher.InstanceNotificationPublisher;
+import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
+import org.apache.stratos.manager.subscription.CartridgeSubscription;
+
+import java.util.Set;
+
+public class RepositoryNotification {
+
+ private static final Log log = LogFactory.getLog(RepositoryNotification.class);
+
+ public void updateRepository(String url) {
+
+ if ( StringUtils.isNotBlank(url)) {
+
+ Set<CartridgeSubscription> cartridgeSubscriptions = new DataInsertionAndRetrievalManager().
+ getCartridgeSubscriptionForRepository(url);
+
+ if (cartridgeSubscriptions == null || cartridgeSubscriptions.isEmpty()) {
+ // No subscriptions, return
+ if (log.isDebugEnabled()) {
+ log.debug("No subscription information found for repo url : " + url);
+ }
+
+ return;
+ }
+
+ for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
+
+ if (cartridgeSubscription.getRepository() != null) {
+ InstanceNotificationPublisher publisher = new InstanceNotificationPublisher();
+ publisher.sendArtifactUpdateEvent(cartridgeSubscription.getRepository(), String.valueOf(cartridgeSubscription.getCluster().getId()),
+ String.valueOf(cartridgeSubscription.getSubscriber().getTenantId()));
+
+ if (log.isDebugEnabled()) {
+ log.debug("Git pull request from " + cartridgeSubscription.getRepository() + "repository, for the tenant " +
+ String.valueOf(cartridgeSubscription.getSubscriber().getTenantId()));
+ }
+
+ } else {
+ if(log.isDebugEnabled()) {
+ log.debug("No repository found for subscription with alias: " + cartridgeSubscription.getAlias() + ", type: " + cartridgeSubscription.getType()+
+ ". Not sending the Artifact Updated event");
+ }
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5c3712c7/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 636f005..d838575 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -40,7 +40,7 @@ import org.apache.stratos.manager.dto.Cartridge;
import org.apache.stratos.manager.dto.SubscriptionInfo;
import org.apache.stratos.manager.exception.*;
import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
-import org.apache.stratos.manager.repository.RepoNotificationServiceClient;
+import org.apache.stratos.manager.repository.RepositoryNotification;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.manager.subscription.DataCartridgeSubscription;
import org.apache.stratos.manager.subscription.PersistenceContext;
@@ -1176,8 +1176,8 @@ public class ServiceUtils {
static void getGitRepositoryNotification(Payload payload) throws RestAPIException {
try {
- RepoNotificationServiceClient repoNotificationServiceClient = getRepoNotificationServiceClient();
- repoNotificationServiceClient.updateRepository(payload.getRepository().getUrl());
+ RepositoryNotification repoNotification = new RepositoryNotification();
+ repoNotification.updateRepository(payload.getRepository().getUrl());
} catch (Exception e) {
String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
@@ -1186,15 +1186,4 @@ public class ServiceUtils {
}
}
- private static RepoNotificationServiceClient getRepoNotificationServiceClient () throws RestAPIException {
-
- try {
- return RepoNotificationServiceClient.getServiceClient();
-
- } catch (AxisFault axisFault) {
- String errorMsg = "Error while getting Reponotification service client. Cause : " + axisFault.getMessage();
- log.error(errorMsg, axisFault);
- throw new RestAPIException(errorMsg, axisFault);
- }
- }
}
[2/2] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-stratos
Posted by ma...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/30279d35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/30279d35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/30279d35
Branch: refs/heads/master
Commit: 30279d356e91c05d89a18ec246868fe1c664b596
Parents: 5c3712c 969ab39
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Thu Mar 13 20:05:42 2014 +0530
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Thu Mar 13 20:05:42 2014 +0530
----------------------------------------------------------------------
.../stratos/manager/manager/CartridgeSubscriptionManager.java | 2 +-
tools/puppet3/modules/agent/templates/bin/stratos.sh.erb | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------