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 09:31:20 UTC
git commit: Git repo notification update
Repository: incubator-stratos
Updated Branches:
refs/heads/master 33e36eb0b -> add6e6d2f
Git repo notification update
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/add6e6d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/add6e6d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/add6e6d2
Branch: refs/heads/master
Commit: add6e6d2f55fd5a3c50a309dfd6b0e68e1211e5a
Parents: 33e36eb
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Thu Mar 13 14:00:04 2014 +0530
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Thu Mar 13 14:00:04 2014 +0530
----------------------------------------------------------------------
.../lookup/RepoUrlToCartridgeSubscriptions.java | 2 +-
.../RepoNotificationServiceClient.java | 45 -----------
.../RepoNotificationServiceClient.java | 84 ++++++++++++++++++++
.../repositoryNotificationInfoBean/Payload.java | 18 +++++
.../Repository.java | 18 +++++
.../rest/endpoint/services/ServiceUtils.java | 5 +-
.../rest/endpoint/services/StratosAdmin.java | 27 +++----
7 files changed, 132 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/add6e6d2/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java
index 740680c..d0d7396 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java
@@ -27,7 +27,7 @@ import java.util.*;
public class RepoUrlToCartridgeSubscriptions {
- private static final Log log = LogFactory.getLog(ClusterIdToSubscription.class);
+ private static final Log log = LogFactory.getLog(RepoUrlToCartridgeSubscriptions.class);
// Map: Repository URL -> Set<CartridgeSubscription>
private Map<String, Set<CartridgeSubscription>> repoUrlToCartridgeSubscriptions;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/add6e6d2/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/reponotification/RepoNotificationServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/reponotification/RepoNotificationServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/reponotification/RepoNotificationServiceClient.java
deleted file mode 100644
index 6ec885f..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/reponotification/RepoNotificationServiceClient.java
+++ /dev/null
@@ -1,45 +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.reponotification;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-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 getPayload(String url) {
- System.out.println("Repo URL : " + url);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/add6e6d2/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
new file mode 100644
index 0000000..0b0ea86
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepoNotificationServiceClient.java
@@ -0,0 +1,84 @@
+/*
+* 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/add6e6d2/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Payload.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Payload.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Payload.java
index 0ffe0e7..50d8a33 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Payload.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Payload.java
@@ -1,3 +1,21 @@
+/*
+* 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.rest.endpoint.bean.repositoryNotificationInfoBean;
import javax.xml.bind.annotation.XmlRootElement;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/add6e6d2/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Repository.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Repository.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Repository.java
index 228f531..5a80596 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Repository.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/repositoryNotificationInfoBean/Repository.java
@@ -1,3 +1,21 @@
+/*
+* 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.rest.endpoint.bean.repositoryNotificationInfoBean;
import javax.xml.bind.annotation.XmlRootElement;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/add6e6d2/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 c70ec0f..636f005 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.reponotification.RepoNotificationServiceClient;
+import org.apache.stratos.manager.repository.RepoNotificationServiceClient;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.manager.subscription.DataCartridgeSubscription;
import org.apache.stratos.manager.subscription.PersistenceContext;
@@ -61,7 +61,6 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.Autosca
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean;
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean;
import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload;
-import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository;
import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
@@ -1178,7 +1177,7 @@ public class ServiceUtils {
try {
RepoNotificationServiceClient repoNotificationServiceClient = getRepoNotificationServiceClient();
- repoNotificationServiceClient.getPayload(payload.getRepository().getUrl());
+ repoNotificationServiceClient.updateRepository(payload.getRepository().getUrl());
} catch (Exception e) {
String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/add6e6d2/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index 86a06e5..8198848 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -301,7 +301,6 @@ public class StratosAdmin extends AbstractAdmin {
return cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()]);
}
-
@GET
@Path("/cartridge/list/subscribed")
@Produces("application/json")
@@ -352,7 +351,6 @@ public class StratosAdmin extends AbstractAdmin {
return ServiceUtils.getActiveInstances(cartridgeType, subscriptionAlias, getConfigContext());
}
-
@POST
@Path("/cartridge/subscribe")
@Produces("application/json")
@@ -519,7 +517,6 @@ public class StratosAdmin extends AbstractAdmin {
return stratosAdminResponse;
}
-
@PUT
@Path("/tenant")
@Consumes("application/json")
@@ -756,7 +753,6 @@ public class StratosAdmin extends AbstractAdmin {
return stratosAdminResponse;
}
-
@GET
@Path("/tenant/list")
@Produces("application/json")
@@ -792,7 +788,6 @@ public class StratosAdmin extends AbstractAdmin {
return tenantList.toArray(new TenantInfoBean[tenantList.size()]);
}
-
@POST
@Path("tenant/activate/{tenantDomain}")
@Consumes("application/json")
@@ -896,7 +891,6 @@ public class StratosAdmin extends AbstractAdmin {
return stratosAdminResponse;
}
-
@POST
@Path("/service/definition")
@Produces("application/json")
@@ -946,7 +940,6 @@ public class StratosAdmin extends AbstractAdmin {
return ServiceUtils.getActiveDeployedServiceInformation(getConfigContext());
}
-
@DELETE
@Path("/service/definition/{serviceType}")
@Produces("application/json")
@@ -959,6 +952,15 @@ public class StratosAdmin extends AbstractAdmin {
return ServiceUtils.undeployService(serviceType);
}
+ @POST
+ @Path("/reponotification")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ public void getRepoNotification(Payload payload) throws RestAPIException {
+
+ ServiceUtils.getGitRepositoryNotification(payload);
+ }
private List<TenantInfoBean> getAllTenants() throws RestAPIException {
TenantManager tenantManager = ServiceHolder.getTenantManager();
@@ -998,15 +1000,4 @@ public class StratosAdmin extends AbstractAdmin {
}
return tenantList;
}
-
- // Repo notification
- @POST
- @Path("/reponotification")
- @Produces("application/json")
- @Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public void getRepoNotification(Payload payload) throws RestAPIException {
-
- ServiceUtils.getGitRepositoryNotification(payload);
- }
}