Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-02-17 20:10:36 +0000
committerjmisinco2014-02-20 13:43:12 +0000
commit432afaa9a00231228b69729dd5798feb257f11e3 (patch)
treed5c079fd6e8ff8a6664922eadbb30d9210f89d45 /plugins/org.eclipse.osee.framework.manager.servlet
parent7c1c9de8a35b4e02bbf13eb0a2f2f834b4671621 (diff)
downloadorg.eclipse.osee-432afaa9a00231228b69729dd5798feb257f11e3.tar.gz
org.eclipse.osee-432afaa9a00231228b69729dd5798feb257f11e3.tar.xz
org.eclipse.osee-432afaa9a00231228b69729dd5798feb257f11e3.zip
bug[ats_ATS21615]: Creation of baseline branch causes exception
Diffstat (limited to 'plugins/org.eclipse.osee.framework.manager.servlet')
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/branch.update.event.handler.xml1
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/BranchUpdateEventHandler.java19
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServerBranchUpdateNotifier.java (renamed from plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServerBranchUpdateOperation.java)61
3 files changed, 62 insertions, 19 deletions
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/branch.update.event.handler.xml b/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/branch.update.event.handler.xml
index 27e61013659..e595b384cbb 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/branch.update.event.handler.xml
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/branch.update.event.handler.xml
@@ -9,4 +9,5 @@
<reference bind="setServerLookup" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IApplicationServerLookup" name="IApplicationServerLookup" policy="static"/>
<reference bind="setAppServerManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IApplicationServerManager" name="IApplicationServerManager" policy="static"/>
<property name="event.topics" type="String" value="org/eclipse/osee/orcs/event/branch/MODIFIED"/>
+ <reference bind="setExecutor" cardinality="1..1" interface="org.eclipse.osee.executor.admin.ExecutorAdmin" name="ExecutorAdmin" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/BranchUpdateEventHandler.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/BranchUpdateEventHandler.java
index d83f6268fc6..d206edc8b86 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/BranchUpdateEventHandler.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/BranchUpdateEventHandler.java
@@ -16,9 +16,8 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.osee.event.Event;
import org.eclipse.osee.event.EventHandler;
+import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.core.server.IApplicationServerLookup;
import org.eclipse.osee.framework.core.server.IApplicationServerManager;
import org.eclipse.osee.framework.core.translation.IDataTranslationService;
@@ -34,6 +33,11 @@ public class BranchUpdateEventHandler implements EventHandler {
private IDataTranslationService translationService;
private IApplicationServerLookup lookupService;
private IApplicationServerManager manager;
+ private ExecutorAdmin executor;
+
+ public void setExecutor(ExecutorAdmin executor) {
+ this.executor = executor;
+ }
public void setLogger(Log logger) {
this.logger = logger;
@@ -66,9 +70,14 @@ public class BranchUpdateEventHandler implements EventHandler {
}
}
if (!branchToUpdate.isEmpty()) {
- IOperation operation =
- new ServerBranchUpdateOperation(logger, translationService, manager, lookupService, branchToUpdate);
- Operations.executeAsJob(operation, false);
+ ServerBranchUpdateNotifier notifier =
+ new ServerBranchUpdateNotifier(logger, translationService, manager, lookupService, branchToUpdate,
+ executor);
+ try {
+ notifier.notifyServers();
+ } catch (Exception ex) {
+ logger.error(ex, "Error notifying other servers");
+ }
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServerBranchUpdateOperation.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServerBranchUpdateNotifier.java
index 039fc893ca0..2f6dcdae34d 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServerBranchUpdateOperation.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServerBranchUpdateNotifier.java
@@ -10,21 +10,25 @@
*******************************************************************************/
package org.eclipse.osee.framework.manager.servlet.internal;
+import java.net.URI;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.framework.core.data.OseeServerContext;
-import org.eclipse.osee.framework.core.data.OseeServerInfo;
import org.eclipse.osee.framework.core.enums.CacheOperation;
import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
import org.eclipse.osee.framework.core.message.BranchCacheStoreRequest;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.server.IApplicationServerLookup;
import org.eclipse.osee.framework.core.server.IApplicationServerManager;
import org.eclipse.osee.framework.core.translation.IDataTranslationService;
import org.eclipse.osee.framework.core.util.HttpMessage;
+import org.eclipse.osee.framework.core.util.HttpProcessor;
import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
import org.eclipse.osee.framework.jdk.core.util.HttpUrlBuilder;
import org.eclipse.osee.logger.Log;
@@ -35,26 +39,26 @@ import org.eclipse.osee.logger.Log;
*
* @author Roberto E. Escobar
*/
-public class ServerBranchUpdateOperation extends AbstractOperation {
+public class ServerBranchUpdateNotifier {
private final Log logger;
private final IDataTranslationService translationService;
private final IApplicationServerLookup lookupService;
private final IApplicationServerManager manager;
+ private final ExecutorAdmin executor;
private final Collection<Branch> branches;
- public ServerBranchUpdateOperation(Log logger, IDataTranslationService translationService, IApplicationServerManager manager, IApplicationServerLookup lookUpProvider, Collection<Branch> branches) {
- super("Server Sync", "org.eclipse.osee.framework.manager.servlet");
+ public ServerBranchUpdateNotifier(Log logger, IDataTranslationService translationService, IApplicationServerManager manager, IApplicationServerLookup lookUpProvider, Collection<Branch> branches, ExecutorAdmin executor) {
this.logger = logger;
this.translationService = translationService;
this.lookupService = lookUpProvider;
this.manager = manager;
this.branches = branches;
+ this.executor = executor;
}
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
+ public void notifyServers() throws Exception {
logger.trace("Sending server update event for [%s]", branches);
BranchCacheStoreRequest request = BranchCacheStoreRequest.fromCache(branches);
@@ -63,22 +67,51 @@ public class ServerBranchUpdateOperation extends AbstractOperation {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("function", CacheOperation.STORE.name());
- for (OseeServerInfo serverInfo : lookupService.getAvailableServers()) {
- if (!manager.getId().equals(serverInfo.getServerId()) && serverInfo.isAcceptingRequests()) {
+ List<Future<Void>> futures = new LinkedList<Future<Void>>();
+
+ for (URI serverUri : lookupService.getAvailableServerUris()) {
+ if (!manager.getServerUri().equals(serverUri)) {
+ ServerUpdateWorker worker = new ServerUpdateWorker(serverUri, parameters, request);
+ Future<Void> future = executor.schedule(worker);
+ futures.add(future);
+ }
+ }
+
+ // wait for all requests to finish
+ for (Future<Void> future : futures) {
+ future.get();
+ }
+ }
+
+ private final class ServerUpdateWorker implements Callable<Void> {
+
+ private final URI serverUri;
+ private final Map<String, String> parameters;
+ private final BranchCacheStoreRequest request;
+
+ public ServerUpdateWorker(URI serverUri, Map<String, String> parameters, BranchCacheStoreRequest request) {
+ this.serverUri = serverUri;
+ this.parameters = parameters;
+ this.request = request;
+ }
+
+ @Override
+ public Void call() throws Exception {
+ if (HttpProcessor.isAlive(serverUri)) {
try {
- String urlString =
- HttpUrlBuilder.createURL(serverInfo.getUri(), OseeServerContext.CACHE_CONTEXT, parameters);
+ String urlString = HttpUrlBuilder.createURL(serverUri, OseeServerContext.CACHE_CONTEXT, parameters);
AcquireResult updateResponse =
HttpMessage.send(urlString, translationService, CoreTranslatorId.BRANCH_CACHE_STORE_REQUEST, request,
null);
if (!updateResponse.wasSuccessful()) {
- logger.error("Error relaying branch updates to servers");
+ logger.error("Unsuccessful response when relaying branch updates to %s", serverUri);
}
} catch (Exception ex) {
- logger.error(ex, "Error relaying branch updates to servers");
+ logger.error(ex, "Error relaying branch updates to %s", serverUri);
}
}
+ return null;
}
}
}

Back to the top