Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2013-11-14 21:55:04 +0000
committerGerrit Code Review @ Eclipse.org2013-12-04 18:05:11 +0000
commit591706db2db166a4d3cd6b4b2f7d2885d7265c62 (patch)
tree013fc47ccbc420434edb9ad41ee2f28c17c411f1 /plugins/org.eclipse.osee.framework.core.server
parentc1c1d3d3113031df4e9661e25e16ffab2c963134 (diff)
downloadorg.eclipse.osee-591706db2db166a4d3cd6b4b2f7d2885d7265c62.tar.gz
org.eclipse.osee-591706db2db166a4d3cd6b4b2f7d2885d7265c62.tar.xz
org.eclipse.osee-591706db2db166a4d3cd6b4b2f7d2885d7265c62.zip
feature[ats_SHB3P]: Remove arbitration code
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.server')
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookup.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookupProvider.java21
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerDataStore.java51
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerLookup.java69
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java11
5 files changed, 25 insertions, 129 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookup.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookup.java
index f2ea180b63a..914c6ff23e7 100644
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookup.java
+++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookup.java
@@ -21,6 +21,4 @@ public interface IApplicationServerLookup {
public Collection<OseeServerInfo> getAvailableServers() throws OseeCoreException;
- public OseeServerInfo getServerInfoBy(String version) throws OseeCoreException;
-
}
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookupProvider.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookupProvider.java
deleted file mode 100644
index ee48fdc79c0..00000000000
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/IApplicationServerLookupProvider.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server;
-
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IApplicationServerLookupProvider {
-
- IApplicationServerLookup getApplicationServerLookupService() throws OseeCoreException;
-}
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerDataStore.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerDataStore.java
index 0d5486bf82a..f0fb871d182 100644
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerDataStore.java
+++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerDataStore.java
@@ -33,9 +33,6 @@ import org.eclipse.osee.logger.Log;
*/
public class ApplicationServerDataStore {
- private static final String GET_NUMBER_OF_SESSIONS =
- "SELECT count(1) FROM osee_session WHERE managed_by_server_id = ?";
-
private static final String SELECT_FROM_LOOKUP_TABLE =
"SELECT * FROM osee_server_lookup ORDER BY server_uri desc, version_id desc";
@@ -58,20 +55,20 @@ public class ApplicationServerDataStore {
return dbService;
}
- public void create(Iterable<? extends OseeServerInfo> infos) throws OseeCoreException {
- executeTx(TxType.CREATE, infos);
+ public void create(OseeServerInfo info) throws OseeCoreException {
+ executeTx(TxType.CREATE, info);
}
- public void update(Iterable<? extends OseeServerInfo> infos) throws OseeCoreException {
- executeTx(TxType.UPDATE, infos);
+ public void update(OseeServerInfo info) throws OseeCoreException {
+ executeTx(TxType.UPDATE, info);
}
- public void delete(Iterable<? extends OseeServerInfo> infos) throws OseeCoreException {
- executeTx(TxType.DELETE, infos);
+ public void delete(OseeServerInfo info) throws OseeCoreException {
+ executeTx(TxType.DELETE, info);
}
- private void executeTx(TxType op, Iterable<? extends OseeServerInfo> infos) throws OseeCoreException {
- IDbTransactionWork tx = new ServerLookupTx(getDbService(), op, infos);
+ private void executeTx(TxType op, OseeServerInfo info) throws OseeCoreException {
+ IDbTransactionWork tx = new ServerLookupTx(getDbService(), op, info);
DatabaseTransactions.execute(getDbService(), getDbService().getConnection(), tx);
}
@@ -131,10 +128,6 @@ public class ApplicationServerDataStore {
}
}
- public int getNumberOfSessions(String serverId) throws OseeCoreException {
- return getDbService().runPreparedQueryFetchObject(0, GET_NUMBER_OF_SESSIONS, serverId);
- }
-
private static enum TxType {
CREATE,
UPDATE,
@@ -149,13 +142,13 @@ public class ApplicationServerDataStore {
private static final String DELETE_FROM_LOOKUP_TABLE_BY_ID = "DELETE FROM osee_server_lookup WHERE server_id = ?";
private final TxType txType;
- private final Iterable<? extends OseeServerInfo> datas;
+ private final OseeServerInfo data;
private final IOseeDatabaseService dbService;
- public ServerLookupTx(IOseeDatabaseService dbService, TxType txType, Iterable<? extends OseeServerInfo> datas) {
+ public ServerLookupTx(IOseeDatabaseService dbService, TxType txType, OseeServerInfo data) {
this.dbService = dbService;
this.txType = txType;
- this.datas = datas;
+ this.data = data;
}
@Override
@@ -182,16 +175,14 @@ public class ApplicationServerDataStore {
private void create(OseeConnection connection) throws OseeCoreException {
List<Object[]> insertData = new ArrayList<Object[]>();
- for (OseeServerInfo data : datas) {
- String serverId = data.getServerId();
- URI serverUri = data.getUri();
- String uri = serverUri.toString();
- Timestamp dateStarted = data.getDateStarted();
- int acceptingRequests = data.isAcceptingRequests() ? 1 : 0;
-
- for (String version : data.getVersion()) {
- insertData.add(new Object[] {serverId, version, uri, dateStarted, acceptingRequests});
- }
+ String serverId = data.getServerId();
+ URI serverUri = data.getUri();
+ String uri = serverUri.toString();
+ Timestamp dateStarted = data.getDateStarted();
+ int acceptingRequests = data.isAcceptingRequests() ? 1 : 0;
+
+ for (String version : data.getVersion()) {
+ insertData.add(new Object[] {serverId, version, uri, dateStarted, acceptingRequests});
}
if (!insertData.isEmpty()) {
dbService.runBatchUpdate(connection, INSERT_LOOKUP_TABLE, insertData);
@@ -205,9 +196,7 @@ public class ApplicationServerDataStore {
private void delete(OseeConnection connection) throws OseeCoreException {
List<Object[]> deleteData = new ArrayList<Object[]>();
- for (OseeServerInfo data : datas) {
- deleteData.add(new Object[] {data.getServerId()});
- }
+ deleteData.add(new Object[] {data.getServerId()});
if (!deleteData.isEmpty()) {
dbService.runBatchUpdate(connection, DELETE_FROM_LOOKUP_TABLE_BY_ID, deleteData);
}
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerLookup.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerLookup.java
index c80ef0e1fdb..85ea7075938 100644
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerLookup.java
+++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerLookup.java
@@ -12,16 +12,12 @@ package org.eclipse.osee.framework.core.server.internal;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.osee.framework.core.data.OseeServerInfo;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.server.IApplicationServerLookup;
import org.eclipse.osee.framework.core.util.HttpProcessor;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.logger.Log;
/**
@@ -80,71 +76,6 @@ public class ApplicationServerLookup implements IApplicationServerLookup {
return healthyServers;
}
- @Override
- public OseeServerInfo getServerInfoBy(String version) throws OseeCoreException {
- Collection<? extends OseeServerInfo> infos = getVersionCompatibleServers(version);
- Collection<OseeServerInfo> healthyServers = getHealthyServers(infos);
- return getBestAvailable(healthyServers);
- }
-
- public Collection<OseeServerInfo> getVersionCompatibleServers(String clientVersion) throws OseeCoreException {
- Set<OseeServerInfo> toReturn = new HashSet<OseeServerInfo>();
- if (Strings.isValid(clientVersion)) {
- Collection<? extends OseeServerInfo> infos = getDataStore().getAll();
- for (OseeServerInfo info : infos) {
- if (isServerCompatible(info, clientVersion)) {
- toReturn.add(info);
- }
- }
- }
- return toReturn;
- }
-
- private boolean isCompatibleVersion(String serverVersion, String clientVersion) {
- boolean result = false;
- if (serverVersion.equals(clientVersion)) {
- result = true;
- } else {
- result = clientVersion.matches(serverVersion);
- if (!result) {
- result = serverVersion.matches(clientVersion);
- }
- }
- return result;
- }
-
- private boolean isServerCompatible(OseeServerInfo info, String clientVersion) {
- boolean result = false;
- for (String version : info.getVersion()) {
- result = isCompatibleVersion(version, clientVersion);
- if (result) {
- break;
- }
- }
- return result;
- }
-
- private OseeServerInfo getBestAvailable(Collection<OseeServerInfo> infos) throws OseeCoreException {
- OseeServerInfo result = null;
- if (infos.size() == 1) {
- result = infos.iterator().next();
- } else {
- int minSessions = Integer.MAX_VALUE;
- for (OseeServerInfo info : infos) {
- try {
- int numberOfSessions = serverDataStore.getNumberOfSessions(info.getServerId());
- if (minSessions > numberOfSessions) {
- result = info;
- minSessions = numberOfSessions;
- }
- } catch (OseeDataStoreException ex) {
- logger.error(ex, "Error getting number of sessions");
- }
- }
- }
- return result;
- }
-
private boolean isServerAlive(OseeServerInfo info) {
return HttpProcessor.isAlive(info.getUri());
}
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java
index c8fde546253..75122990b47 100644
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java
+++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java
@@ -18,7 +18,6 @@ import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -236,7 +235,7 @@ public class ApplicationServerManager implements IApplicationServerManager {
OseeServerInfoMutable info = getApplicationServerInfo();
info.setAcceptingRequests(value);
if (PersistType.ALLOW_DB_PERSIST == persistType) {
- dataStore.update(Collections.singleton(info));
+ dataStore.update(info);
}
for (String contexts : oseeHttpServlets.keySet()) {
InternalOseeHttpServlet servlets = oseeHttpServlets.get(contexts);
@@ -341,7 +340,7 @@ public class ApplicationServerManager implements IApplicationServerManager {
OseeServerInfoMutable info = getApplicationServerInfo();
refreshData(info);
info.addVersion(version);
- dataStore.update(Collections.singleton(info));
+ dataStore.update(info);
}
@Override
@@ -356,7 +355,7 @@ public class ApplicationServerManager implements IApplicationServerManager {
boolean wasRemoved = versions.remove(version);
if (wasRemoved) {
info.setVersions(versions);
- dataStore.update(Collections.singleton(info));
+ dataStore.update(info);
} else {
throw new OseeStateException("Not part of the supported version [%s]", version);
}
@@ -365,7 +364,7 @@ public class ApplicationServerManager implements IApplicationServerManager {
private boolean deregisterWithDb(OseeServerInfo info) {
boolean status = false;
try {
- dataStore.delete(Collections.singleton(info));
+ dataStore.delete(info);
status = true;
} catch (OseeCoreException ex) {
getLogger().info("Server lookup table is not initialized");
@@ -376,7 +375,7 @@ public class ApplicationServerManager implements IApplicationServerManager {
private boolean registerWithDb(OseeServerInfo info) {
boolean status = false;
try {
- dataStore.create(Collections.singleton(info));
+ dataStore.create(info);
status = true;
} catch (OseeCoreException ex) {
getLogger().info("Server lookup table is not initialized");

Back to the top