Issue #2202 Add edex specific connectivity checking.
Change-Id: I003957001ed608d1054ab2a87019b018f8996d36 Former-commit-id:fac4cdc131
[formerly54321b4839
[formerlycfd9cb0b7d
] [formerlyfac4cdc131
[formerly b8e5323b70db03817c6c750746f29cc550cbc815]]] Former-commit-id:54321b4839
[formerlycfd9cb0b7d
] Former-commit-id:54321b4839
Former-commit-id:8eb1bf8c88
This commit is contained in:
parent
75c7a32995
commit
8b52e9d079
9 changed files with 106 additions and 48 deletions
|
@ -20,6 +20,9 @@
|
|||
package com.raytheon.uf.viz.core.comm;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
|
@ -27,6 +30,10 @@ import org.apache.activemq.ActiveMQConnectionFactory;
|
|||
import org.apache.http.client.methods.HttpGet;
|
||||
|
||||
import com.raytheon.uf.common.comm.HttpClient;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersRequest;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersResponse;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* Class for checking connectivity of http servers, currently only used for
|
||||
|
@ -42,8 +49,10 @@ import com.raytheon.uf.common.comm.HttpClient;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 12, 2009 mschenke Initial creation
|
||||
* Mar 22, 2013 1786 mpduff Changed to use HttpClient for connectivity.
|
||||
* Aug 12, 2009 mschenke Initial creation
|
||||
* Mar 22, 2013 1786 mpduff Changed to use HttpClient for
|
||||
* connectivity.
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -53,6 +62,13 @@ import com.raytheon.uf.common.comm.HttpClient;
|
|||
|
||||
public class ConnectivityManager {
|
||||
|
||||
/*
|
||||
* Since a get servers request is used for checking localization server
|
||||
* connectivity, this map will cache the result in case it is needed later.
|
||||
*/
|
||||
private static final Map<String, GetServersResponse> getServersResponseCache = Collections
|
||||
.synchronizedMap(new HashMap<String, GetServersResponse>(2));
|
||||
|
||||
public static class ConnectivityResult {
|
||||
public boolean hasConnectivity;
|
||||
|
||||
|
@ -86,6 +102,43 @@ public class ConnectivityManager {
|
|||
callback.connectionChecked(new ConnectivityResult(good, server));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the connectivity of the given localization server
|
||||
*
|
||||
* @param server
|
||||
* server to check
|
||||
*/
|
||||
public static void checkLocalizationServer(String server, IConnectivityCallback callback) {
|
||||
boolean good = false;
|
||||
try {
|
||||
good = checkLocalizationServer(server, true) != null;
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
callback.connectionChecked(new ConnectivityResult(good, server));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a GetServersResponse for the provided server. If force is false
|
||||
* and this localization server has already been contacted then a cached
|
||||
* result is returned, otherwise the localization server is contacted to get
|
||||
* the response.
|
||||
*/
|
||||
public static GetServersResponse checkLocalizationServer(String server, boolean force)
|
||||
throws VizException {
|
||||
if (!force) {
|
||||
GetServersResponse resp = getServersResponseCache.get(server);
|
||||
if (resp != null) {
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
GetServersRequest req = new GetServersRequest();
|
||||
GetServersResponse resp = (GetServersResponse) ThriftClient.sendRequest(req, server);
|
||||
getServersResponseCache.put(server, resp);
|
||||
return resp;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the connectivity of the given server
|
||||
*
|
||||
|
|
|
@ -56,9 +56,10 @@ import com.raytheon.uf.common.util.FileUtil;
|
|||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 8, 2008 #878 chammack Initial creation
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 08, 2008 878 chammack Initial creation
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -68,9 +69,6 @@ import com.raytheon.uf.common.util.FileUtil;
|
|||
|
||||
public class CAVELocalizationAdapter implements ILocalizationAdapter {
|
||||
|
||||
private static final LocalizationManager manager = LocalizationManager
|
||||
.getInstance();
|
||||
|
||||
private final Map<LocalizationType, LocalizationContext[]> contexts;
|
||||
|
||||
public CAVELocalizationAdapter() {
|
||||
|
@ -170,8 +168,9 @@ public class CAVELocalizationAdapter implements ILocalizationAdapter {
|
|||
context.length);
|
||||
|
||||
if (serverContexts.size() > 0) {
|
||||
List<ListResponseEntry[]> entriesList = manager
|
||||
.getListResponseEntry(context, fileName, true, false);
|
||||
List<ListResponseEntry[]> entriesList = LocalizationManager
|
||||
.getInstance().getListResponseEntry(context, fileName,
|
||||
true, false);
|
||||
|
||||
for (int i = 0; i < context.length; i++) {
|
||||
ListResponseEntry[] entries = entriesList.get(i);
|
||||
|
@ -223,7 +222,7 @@ public class CAVELocalizationAdapter implements ILocalizationAdapter {
|
|||
return;
|
||||
}
|
||||
|
||||
manager.retrieve(file);
|
||||
LocalizationManager.getInstance().retrieve(file);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -241,8 +240,9 @@ public class CAVELocalizationAdapter implements ILocalizationAdapter {
|
|||
InputStream in = null;
|
||||
try {
|
||||
in = new LockingFileInputStream(localFile);
|
||||
long serverModTime = manager.upload(file.getContext(),
|
||||
file.getFileName(), in, localFile.length());
|
||||
long serverModTime = LocalizationManager.getInstance().upload(
|
||||
file.getContext(), file.getFileName(), in,
|
||||
localFile.length());
|
||||
// Success! set potentially changed fields
|
||||
file.setTimeStamp(new Date(serverModTime));
|
||||
file.setIsAvailableOnServer(true);
|
||||
|
@ -374,6 +374,7 @@ public class CAVELocalizationAdapter implements ILocalizationAdapter {
|
|||
List<ListResponse> responses = new ArrayList<ListResponse>(
|
||||
contexts.length);
|
||||
|
||||
LocalizationManager manager = LocalizationManager.getInstance();
|
||||
if (serverContexts.size() > 0) {
|
||||
List<ListResponseEntry[]> entryList = manager.getListResponseEntry(
|
||||
serverContexts
|
||||
|
@ -469,7 +470,8 @@ public class CAVELocalizationAdapter implements ILocalizationAdapter {
|
|||
@Override
|
||||
public boolean delete(ModifiableLocalizationFile file)
|
||||
throws LocalizationOpFailedException {
|
||||
long deleteTime = manager.delete(file.getContext(), file.getFileName());
|
||||
long deleteTime = LocalizationManager.getInstance().delete(
|
||||
file.getContext(), file.getFileName());
|
||||
|
||||
// Made it here! file on server succesfully deleted! Delete local file
|
||||
// reference. If that fails, doesn't matter since file does not exist!
|
||||
|
@ -595,7 +597,8 @@ public class CAVELocalizationAdapter implements ILocalizationAdapter {
|
|||
@Override
|
||||
public String[] getContextList(LocalizationLevel level)
|
||||
throws LocalizationOpFailedException {
|
||||
List<ListResponseEntry[]> entriesList = manager.getContextList(level);
|
||||
List<ListResponseEntry[]> entriesList = LocalizationManager
|
||||
.getInstance().getContextList(level);
|
||||
Set<String> fileList = new HashSet<String>();
|
||||
for (ListResponseEntry[] entryArr : entriesList) {
|
||||
for (ListResponseEntry entry : entryArr) {
|
||||
|
|
|
@ -56,7 +56,8 @@ import com.raytheon.uf.viz.core.comm.IConnectivityCallback;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 5, 2009 mschenke Initial creation
|
||||
* Aug 05, 2009 mschenke Initial creation
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -363,7 +364,7 @@ public class ConnectivityPreferenceDialog extends Dialog {
|
|||
}
|
||||
|
||||
private void validateLocalization() {
|
||||
ConnectivityManager.checkHttpServer(localization, localizationCallback);
|
||||
ConnectivityManager.checkLocalizationServer(localization, localizationCallback);
|
||||
}
|
||||
|
||||
private void validateAlertviz() {
|
||||
|
|
|
@ -28,13 +28,12 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersRequest;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersResponse;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.VizServers;
|
||||
import com.raytheon.uf.viz.core.comm.ConnectivityManager;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* Class that does work of checking localization server, popping up dialog if
|
||||
|
@ -47,9 +46,10 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2009 mschenke Initial creation
|
||||
* Sep 12, 2012 1167 djohnson Add datadelivery servers.
|
||||
* Jan 14, 2013 1469 bkowal Removed the hdf5 data directory.
|
||||
* Nov 05, 2009 mschenke Initial creation
|
||||
* Sep 12, 2012 1167 djohnson Add datadelivery servers.
|
||||
* Jan 14, 2013 1469 bkowal Removed the hdf5 data directory.
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -121,9 +121,9 @@ public class LocalizationInitializer {
|
|||
* @throws VizException
|
||||
*/
|
||||
protected final void processGetServers() throws VizException {
|
||||
GetServersRequest req = new GetServersRequest();
|
||||
GetServersResponse resp = (GetServersResponse) ThriftClient
|
||||
.sendLocalizationRequest(req);
|
||||
GetServersResponse resp = ConnectivityManager.checkLocalizationServer(
|
||||
LocalizationManager.getInstance().getLocalizationServer(),
|
||||
false);
|
||||
VizApp.setHttpServer(resp.getHttpServer());
|
||||
VizApp.setJmsServer(resp.getJmsServer());
|
||||
VizApp.setPypiesServer(resp.getPypiesServer());
|
||||
|
|
|
@ -55,7 +55,6 @@ import com.raytheon.uf.common.localization.msgs.AbstractPrivilegedUtilityCommand
|
|||
import com.raytheon.uf.common.localization.msgs.AbstractUtilityResponse;
|
||||
import com.raytheon.uf.common.localization.msgs.DeleteUtilityCommand;
|
||||
import com.raytheon.uf.common.localization.msgs.DeleteUtilityResponse;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersRequest;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersResponse;
|
||||
import com.raytheon.uf.common.localization.msgs.GetUtilityCommand;
|
||||
import com.raytheon.uf.common.localization.msgs.ListContextCommand;
|
||||
|
@ -73,6 +72,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.viz.application.ProgramArguments;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.VizServers;
|
||||
import com.raytheon.uf.viz.core.comm.ConnectivityManager;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.PrivilegedRequestFactory;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
@ -85,13 +85,14 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 17, 2007 chammack Initial Creation.
|
||||
* Jul 24, 2007 njensen Added upload().
|
||||
* Jul 24, 2007 njensen Added upload().
|
||||
* Jul 30, 2007 njensen Refactored.
|
||||
* Feb 12, 2008 chammack Removed base configuration
|
||||
* Mar 26, 2008 njensen Added rename() and getFileContents().
|
||||
* May 19, 2007 #1127 randerso Implemented error handling
|
||||
* May 19, 2007 1127 randerso Implemented error handling
|
||||
* Sep 12, 2012 1167 djohnson Add datadelivery servers.
|
||||
* Jan 14, 2013 1469 bkowal Removed the hdf5 data directory.
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -217,10 +218,9 @@ public class LocalizationManager implements IPropertyChangeListener {
|
|||
applyChanges();
|
||||
}
|
||||
|
||||
GetServersRequest req = new GetServersRequest();
|
||||
try {
|
||||
GetServersResponse resp = (GetServersResponse) ThriftClient
|
||||
.sendLocalizationRequest(req);
|
||||
GetServersResponse resp = ConnectivityManager.checkLocalizationServer(
|
||||
currentServer, false);
|
||||
VizApp.setHttpServer(resp.getHttpServer());
|
||||
VizApp.setJmsServer(resp.getJmsServer());
|
||||
VizApp.setPypiesServer(resp.getPypiesServer());
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.raytheon.uf.viz.core.comm.IConnectivityCallback;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 18, 2007 chammack Initial Creation.
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -217,7 +218,7 @@ public class LocalizationPreferences extends FieldEditorPreferencePage
|
|||
private void checkConnectivity() {
|
||||
final ConnectivityResult result = new ConnectivityResult(false, "");
|
||||
Text text = localizationEditor.getTextControl(getFieldEditorParent());
|
||||
ConnectivityManager.checkHttpServer(text.getText().trim(),
|
||||
ConnectivityManager.checkLocalizationServer(text.getText().trim(),
|
||||
new IConnectivityCallback() {
|
||||
@Override
|
||||
public void connectionChecked(ConnectivityResult results) {
|
||||
|
|
|
@ -47,8 +47,10 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 8, 2011 mschenke Initial creation
|
||||
* Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a preference.
|
||||
* Nov 08, 2011 mschenke Initial creation
|
||||
* Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a
|
||||
* preference.
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -135,7 +137,7 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage {
|
|||
|
||||
// check HTTP Server
|
||||
Text text = servicesServer.getTextControl(getFieldEditorParent());
|
||||
ConnectivityManager.checkHttpServer(text.getText().trim(),
|
||||
ConnectivityManager.checkLocalizationServer(text.getText().trim(),
|
||||
new IConnectivityCallback() {
|
||||
@Override
|
||||
public void connectionChecked(ConnectivityResult results) {
|
||||
|
|
|
@ -25,14 +25,13 @@ import org.apache.commons.collections.map.DefaultedMap;
|
|||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
||||
import com.raytheon.uf.common.comm.HttpClient;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersRequest;
|
||||
import com.raytheon.uf.common.localization.msgs.GetServersResponse;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.VizServers;
|
||||
import com.raytheon.uf.viz.core.comm.ConnectivityManager;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.localization.LocalizationInitializer;
|
||||
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
import com.raytheon.uf.viz.thinclient.Activator;
|
||||
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
|
||||
import com.raytheon.uf.viz.thinclient.ui.ThinClientConnectivityDialog;
|
||||
|
@ -47,9 +46,10 @@ import com.raytheon.uf.viz.thinclient.ui.ThinClientConnectivityDialog;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 23, 2011 bsteffen Initial creation
|
||||
* Dec 06, 2012 1396 njensen Added setting VizServers
|
||||
* Jan 14, 2013 1469 bkowal Removed setting the hdf5 data directory
|
||||
* Nov 23, 2011 bsteffen Initial creation
|
||||
* Dec 06, 2012 1396 njensen Added setting VizServers
|
||||
* Jan 14, 2013 1469 bkowal Removed setting the hdf5 data directory
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -88,12 +88,9 @@ public class ThinClientLocalizationInitializer extends LocalizationInitializer {
|
|||
.getString(ThinClientPreferenceConstants.P_SERVICES_PROXY);
|
||||
LocalizationManager.getInstance().setCurrentServer(servicesProxy);
|
||||
if (!disableJMS) {
|
||||
GetServersRequest req = new GetServersRequest();
|
||||
GetServersResponse resp = (GetServersResponse) ThriftClient
|
||||
.sendLocalizationRequest(req);
|
||||
if (!disableJMS) {
|
||||
VizApp.setJmsServer(resp.getJmsServer());
|
||||
}
|
||||
GetServersResponse resp = ConnectivityManager.checkLocalizationServer(
|
||||
servicesProxy, false);
|
||||
VizApp.setJmsServer(resp.getJmsServer());
|
||||
}
|
||||
VizApp.setHttpServer(servicesProxy);
|
||||
VizApp.setPypiesServer(store
|
||||
|
|
|
@ -53,7 +53,8 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 23, 2011 bsteffen Initial creation
|
||||
* Nov 23, 2011 bsteffen Initial creation
|
||||
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -237,7 +238,7 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
|
|||
}
|
||||
|
||||
private void validateServices() {
|
||||
ConnectivityManager.checkHttpServer(services, servicesCallback);
|
||||
ConnectivityManager.checkLocalizationServer(services, servicesCallback);
|
||||
}
|
||||
|
||||
private void validatePypies() {
|
||||
|
|
Loading…
Add table
Reference in a new issue