[simias-svn] SF.net SVN: simias:[7391] trunk/src
Brought to you by:
srinidhi_bs
|
From: <he...@us...> - 2010-06-09 11:20:34
|
Revision: 7391
http://simias.svn.sourceforge.net/simias/?rev=7391&view=rev
Author: hegdegg
Date: 2010-06-09 11:20:23 +0000 (Wed, 09 Jun 2010)
Log Message:
-----------
Fix for updating the new master information for 2nd server in
multiserver setup.
Modified Paths:
--------------
trunk/src/admin/ServerDetails.aspx.cs
trunk/src/admin/iFolderAdmin.resx
trunk/src/core/CollectionStore/Collection.cs
trunk/src/webservices/iFolderServer.cs
Modified: trunk/src/admin/ServerDetails.aspx.cs
===================================================================
--- trunk/src/admin/ServerDetails.aspx.cs 2010-06-08 14:00:58 UTC (rev 7390)
+++ trunk/src/admin/ServerDetails.aspx.cs 2010-06-09 11:20:23 UTC (rev 7391)
@@ -516,6 +516,8 @@
{
log.Info("This server needs a repair");
remoteweb.RepairChangeMasterUpdates();
+ server = web.GetServer( ServerID );
+ Type.Text = GetString( server.IsMaster ? "MASTER" : "SLAVE" );
}
}
catch (WebException ex)
@@ -586,16 +588,17 @@
remoteweb.Url = turl.ToString();
redirectUrl = remoteweb.Url;
remoteweb.Url = remoteweb.Url + "/iFolderAdmin.asmx";
-// TopNav.ShowInfo (String.Format("WebException-noproto {0} ", remoteweb.Url));
+ log.Info (String.Format("Connecting to {0} ", remoteweb.Url));
try
{
remoteweb.GetAuthenticatedUser();
}
- //catch (WebException ex1)
- catch
+ catch (Exception ex1)
+ //catch
{
// TopNav.ShowInfo (String.Format("WebException-noproto {0} {1}", ex1.Status, remoteweb.Url));
+ log.Info (String.Format("Exception-noproto {0} {1}", ex1.StackTrace, ex1.Message));
remoteweb = web;
Status.Text = String.Format("<font color=red><b>" + GetString("OFFLINE") + "</b></font>");
serverStatus = false;
@@ -649,6 +652,7 @@
MasterIP.Visible = MasterIP.Enabled = true;
MasterIP.Text = ldapInfo.MasterURL;
MasterUri.Text = GetString( "MASTERURI" );
+ ChangeMasterButton.Visible = true;
ChangeMasterButton.Enabled = true;
}
else
@@ -656,6 +660,7 @@
MasterIP.Enabled = false;
MasterIP.Text = "";
MasterUri.Text = "";
+ ChangeMasterButton.Visible = false;
ChangeMasterButton.Enabled = false;
}
@@ -1284,6 +1289,7 @@
remoteWebServer.PreAuthenticate = true;
remoteWebServer.Credentials = web.Credentials;
remoteWebServer.Url = connectUrl+ "/iFolderAdmin.asmx";
+ log.Info("Connecting to : {0}", remoteWebServer.Url);
while ( count <= retryCount)
{
@@ -1320,6 +1326,7 @@
remoteWebServer.PreAuthenticate = true;
remoteWebServer.Credentials = web.Credentials;
remoteWebServer.Url = connectUrl + "/iFolderAdmin.asmx";
+ log.Info("Connecting to : {0}", remoteWebServer.Url);
while ( count <= retryCount)
{
@@ -1346,8 +1353,8 @@
/// <summary>
/// Wrapper funtion to call SetAsMasterNodeAttribute
/// </summary>
+ /// <param name="connectUrl">Url of the server</param>
/// <param name="serverID">ID of the server</param>
- /// <param name="ServerURL">Url of the server</param>
/// <param name="nodeValue">true/false for master/slave</param>
protected bool SetMasterNode(string connectUrl, string serverID, bool nodeValue)
{
@@ -1358,6 +1365,7 @@
remoteWebServer.PreAuthenticate = true;
remoteWebServer.Credentials = web.Credentials;
remoteWebServer.Url = connectUrl + "/iFolderAdmin.asmx";
+ log.Info("Connecting to : {0}", remoteWebServer.Url);
while ( count <= retryCount)
{
@@ -1409,9 +1417,9 @@
if (retval != checkVal)
{
log.Info("Waiting for master node attrituge to sync accross old and new master server");
- Thread.Sleep(1000);
+ Thread.Sleep(5000);
}
- loop++;
+ loop++; count ++;
}
}
catch(Exception ex)
@@ -1436,6 +1444,7 @@
/// <param name="ServerURL">Url of the server</param>
protected bool SetMasterURL(string connectURL, string serverID, string serverURL)
{
+ log.Info("SetMasterURL");
int count = 0;
bool retval = false;
iFolderAdmin otherSlaveServers = new iFolderAdmin();
@@ -1448,13 +1457,14 @@
{
try
{
+ log.Info("will call setmasterUrls : {0} :{1} ", serverID, serverURL);
retval = otherSlaveServers.SetMasterServerUrl(serverID, serverURL);
break;
}
catch(Exception ex)
{
log.Info("Caught exception while SetMasterURL : {0} : {1}", ex.Message, ex.StackTrace);
- if (ex.Message.IndexOf("InvalidOperation") >= 0)
+ if (ex.Message.IndexOf("InvalidOperation") >= 0 )
{
count ++;
continue;
@@ -1544,6 +1554,7 @@
TopNav.ShowError(GetString("UNABLETOSETASMASTER"));
return;
}
+ log.Info("SetAsMaster Complete. Setting Node attributes");
// Master and Slave updated, now set the Master node attribute for new Master host on both
// current master and new master
if ( SetMasterNode(mServer.PublicUrl, mServer.ID, true))
@@ -1564,12 +1575,13 @@
StringBuilder failedServers = new System.Text.StringBuilder();
foreach(iFolderServer ifs in iFolderServers)
{
- if ( ifs.HostName != newmServer.HostName)
+ log.Info("Calling server : {0}: {1}", ifs.Name, ifs.PublicUrl);
+ if ( ifs.Name != newmServer.Name && ifs.Name != mServer.Name )
{
- if (SetMasterURL(ifs.PublicUrl, ServerID, newServerPublicUrl) != true)
+ if (SetMasterURL(ifs.PublicUrl.ToString(), ServerID, newServerPublicUrl) != true)
{
log.Info("Update master serverurl on {0} failed ", ifs.PublicUrl);
- list.Add(ifs.HostName);
+ list.Add(ifs.Name);
}
}
}
@@ -1580,7 +1592,6 @@
failedServers.Append(list[i].ToString()).Append(" ");
}
log.Info("Unable to set master url on : {0}", failedServers.ToString());
- TopNav.ShowError(GetString("UPDATEMASTERURLONSLAVEFAILED") + failedServers.ToString());
}
else
{
@@ -1590,7 +1601,6 @@
else
{
log.Info(String.Format ("Unable to get new Master ServerID and newServerPublicUrl, retry"));
- TopNav.ShowError(GetString("CHANGEMASTERINFOFAILED"));
}
}
else
@@ -1601,17 +1611,14 @@
finally
{
ChangeMasterButton.Enabled = false;
- /* this is just to get all the changes done on both the
- servers. does nothing other than logging. Will be useful
- for debuggind in case of any error */
- if (mServer != null && newmServer != null)
- web.VerifyChangeMaster(mServer.ID, newmServer.ID);
if (currentMasterUpdateComplete && newMasterUpdateComplete &&
slaveUpdateComplete)
{
- TopNav.ShowInfo (String.Format (GetString ("CHANGEMASTERSUCCESSFUL"), newServerPublicUrl));
+ TopNav.ShowInfo (String.Format (GetString ("CHANGEMASTERSUCCESSFUL"), newmServer.Name));
}
+ else
+ TopNav.ShowInfo (String.Format (GetString ("CHANGEMASTERWITHWARNING"), newmServer.Name));
}
return;
}
Modified: trunk/src/admin/iFolderAdmin.resx
===================================================================
--- trunk/src/admin/iFolderAdmin.resx 2010-06-08 14:00:58 UTC (rev 7390)
+++ trunk/src/admin/iFolderAdmin.resx 2010-06-09 11:20:23 UTC (rev 7391)
@@ -1300,8 +1300,11 @@
<value>Unable to get Server ID and New Server Public URL.</value>
</data>
<data name="CHANGEMASTERSUCCESSFUL">
- <value>Successfully changed the Master and Slave. New Master is {0}. Restart all servers for the changes to take effect.</value>
+ <value>Upgraded {0} as master server. Restart all servers for the changes to take effect.</value>
</data>
+ <data name="CHANGEMASTERWITHWARNING">
+ <value>Upgraded {0} as master server with exceptions. Refer Simias.log for more info. Restart all servers for the changes to take effect.</value>
+ </data>
<data name="CHANGEMASTERFAILED">
<value>Unable to change the Master and Slave. Check log files for more information.</value>
</data>
Modified: trunk/src/core/CollectionStore/Collection.cs
===================================================================
--- trunk/src/core/CollectionStore/Collection.cs 2010-06-08 14:00:58 UTC (rev 7390)
+++ trunk/src/core/CollectionStore/Collection.cs 2010-06-09 11:20:23 UTC (rev 7391)
@@ -820,7 +820,7 @@
{
if (value != null && value.Length != 0)
{
- Property p = new Property( PropertyTags.HostUri, value );
+ Property p = new Property( PropertyTags.HostUri, new Uri(value) );
p.LocalProperty = true;
properties.ModifyNodeProperty( p );
}
Modified: trunk/src/webservices/iFolderServer.cs
===================================================================
--- trunk/src/webservices/iFolderServer.cs 2010-06-08 14:00:58 UTC (rev 7390)
+++ trunk/src/webservices/iFolderServer.cs 2010-06-09 11:20:23 UTC (rev 7391)
@@ -87,7 +87,6 @@
[Serializable]
public class iFolderServer
{
- internal static string catalogID = "a93266fd-55de-4590-b1c7-428f2fed815d"; //TODO: refer.
/// <summary>
/// iFolder Log Instance
/// </summary>
@@ -252,7 +251,6 @@
string host = ldapSettings.Host;
bool SSL = ldapSettings.SSL;
string proxydn = ldapSettings.ProxyDN;
- string proxypwd = ldapSettings.ProxyPassword;
ProxyUser pu = new Simias.LdapProvider.ProxyUser();
string pwd2 = pu.Password;
string proxyfilename = "ldapdetails";
@@ -763,7 +761,6 @@
string ServerSection="Server";
string PublicAddressKey = "PublicAddress";
string PrivateAddressKey = "PrivateAddress";
- string MasterAddressKey = "MasterAddress";
if (!privateUrl.ToLower().StartsWith(Uri.UriSchemeHttp))
{
privateUrl = (new UriBuilder(Uri.UriSchemeHttp, privateUrl)).ToString();
@@ -797,28 +794,25 @@
{
// going to update the config file
// Load the configuration file into an xml document.
- XmlDocument document = new XmlDocument();
- document.Load(SimiasConfigFilePath );
+ XmlDocument document = new XmlDocument();
+ document.Load(SimiasConfigFilePath );
-
SetConfigValue( document, ServerSection, PublicAddressKey, publicUrl );
- SetConfigValue( document, ServerSection, PrivateAddressKey, privateUrl );
+ SetConfigValue( document, ServerSection, PrivateAddressKey, privateUrl );
if(MasterUrl != "")
- {
- /// it means its a slave server, so set the masters IP into config file
- UpdateStatus = SetConfigValueWithSSL( document, ServerSection, MasterAddressKey, MasterUrl );
- if(UpdateStatus == false)
- return false;
+ {
+ //verify and update simias too.
+ UpdateSimiasAndConfig(MasterUrl);
if (MasterUrl != null)
{
UpdateStatus = UpdateMasterURL(MasterUrl);
if(UpdateStatus == false)
return false;
}
- }
+ }
// Commit the config file changes.
- CommitConfiguration( document , SimiasConfigFilePath);
+ CommitConfiguration( document , SimiasConfigFilePath);
UpdateStatus = true;
}
catch(Exception ex)
@@ -840,7 +834,7 @@
bool needsRepair= false;
Store store = Store.GetStore();
Domain domain = store.GetDomain(store.DefaultDomain);
- Collection cat = store.GetCollectionByID(catalogID); //Simias.Server.Catalog.catalogID);
+ Collection cat = store.GetCollectionByID(Simias.Server.Catalog.catalogID);
HostNode localhostNode = HostNode.GetLocalHost();
@@ -890,12 +884,28 @@
}
catch (Exception ex)
{
- log.Info("Exception throw while RepairChangeMasterUpdate()");
+ log.Error("Exception throw while RepairChangeMasterUpdate() : {0}", ex.StackTrace);
status = false;
}
return status;
}
+ public static bool UpdateSimiasAndConfig(string MasterUrl)
+ {
+ bool status = false;
+ Store store = Store.GetStore();
+ Domain domain = store.GetDomain(store.DefaultDomain);
+ if ( domain.HostUri == MasterUrl)
+ {
+ status = SetMasterServerUrl(domain.HostID, domain.HostUri);
+ }
+ else
+ {
+ log.Error("New master url does not match with iFolder domain master url");
+ }
+ return status;
+ }
+
/// <summary>
/// This method is used to set the Master server url into simias.config file.
/// </summary>
@@ -905,25 +915,26 @@
bool UpdateStatus = false;
string ServerSection="Server";
string MasterAddressKey = "MasterAddress";
-
- if (MasterUrl != null && !MasterUrl.ToLower().StartsWith(Uri.UriSchemeHttps))
- {
- MasterUrl = (new UriBuilder(Uri.UriSchemeHttps, MasterUrl)).ToString();
- }
try
{
Store store = Store.GetStore();
Domain domain = store.GetDomain(store.DefaultDomain);
- HostNode localhostNode = HostNode.GetLocalHost();
domain.HostID = HostID;
- domain.HostUri = MasterUrl;
+ domain.HostUri = MasterUrl;
domain.Commit();
+ Collection cat = store.GetCollectionByID(Simias.Server.Catalog.catalogID);
+ cat.HostID = HostID;
+ cat.Commit(cat);
string SimiasConfigFilePath = Path.Combine ( Store.StorePath, "Simias.config");
if ( File.Exists( Path.Combine( Store.StorePath, Simias.Configuration.DefaultConfigFileName ) ) == true )
{
SimiasConfigFilePath = Path.Combine( Store.StorePath, Simias.Configuration.DefaultConfigFileName );
}
+ else
+ {
+ log.Info("Simias.config file does not exist");
+ }
XmlDocument document = new XmlDocument();
document.Load(SimiasConfigFilePath );
UpdateStatus = SetConfigValueWithSSL( document, ServerSection, MasterAddressKey, MasterUrl );
@@ -955,7 +966,7 @@
{
Store store = Store.GetStore();
Domain domain = store.GetDomain(store.DefaultDomain);
- Collection cat = store.GetCollectionByID(catalogID); //Simias.Server.Catalog.catalogID);
+ Collection cat = store.GetCollectionByID(Simias.Server.Catalog.catalogID);
HostNode localhostNode = HostNode.GetLocalHost();
@@ -979,6 +990,7 @@
domain.Role = Simias.Sync.SyncRoles.Slave;
log.Info("Setting SyncRole on the Domain to Slave ({0})", domain.Role);
+ domain.SystemSyncStatus = (domain.SystemSyncStatus | (ulong)Simias.Sync.CollectionSyncClient.StateMap.CatalogSyncOnce) ;
// Updating Catalog
cat.Role = Simias.Sync.SyncRoles.Slave;
log.Info("Setting SyncRole on the catalog");
@@ -1035,7 +1047,7 @@
{
Store store = Store.GetStore();
Domain domain = store.GetDomain(store.DefaultDomain);
- Collection cat = store.GetCollectionByID(catalogID); //Simias.Server.Catalog.catalogID);
+ Collection cat = store.GetCollectionByID(Simias.Server.Catalog.catalogID);
HostNode localhostNode = HostNode.GetHostByID(domain.ID, HostID);
@@ -1162,7 +1174,7 @@
{
Store store = Store.GetStore();
Domain domain = store.GetDomain(store.DefaultDomain);
- Collection cat = store.GetCollectionByID(catalogID); //Simias.Server.Catalog.catalogID);
+ Collection cat = store.GetCollectionByID(Simias.Server.Catalog.catalogID);
HostNode currentMasterNode = HostNode.GetHostByID(domain.ID, currentMasterID);
HostNode newMasterNode = HostNode.GetHostByID(domain.ID, newMasterID);
@@ -1185,9 +1197,8 @@
log.Info("IsMasterHost : {0}", newMasterNode.IsMasterHost);
log.Info("ChangeMasterState : {0}", newMasterNode.ChangeMasterState);
}
- catch (Exception ex)
+ catch
{
- log.Error("Uable to verify change master");
retval = false;
}
return retval;
@@ -1209,7 +1220,7 @@
masterNode.PrivateUrl = masterUrl;
domain.Commit(masterNode);
}
- catch (Exception ex)
+ catch
{
retVal = false;
}
@@ -1371,7 +1382,7 @@
if (masterAddress.ToLower().StartsWith(Uri.UriSchemeHttps))
{
string machineArch = GetServerArch();
- string webPath = webPath = Path.GetFullPath("../../../../lib/simias/web");
+ string webPath = Path.GetFullPath("../../../../lib/simias/web");
if (machineArch != null)
{
@@ -1379,29 +1390,31 @@
}
// swap policy
+ ICertificatePolicy policy = ServicePointManager.CertificatePolicy;
ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
- HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(masterAddress);
+ HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(RemoveVirtualPath(masterAddress));
+ log.Debug("Master URL is {0}", RemoveVirtualPath(masterAddress));
try
{
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+ request.GetResponse();
}
- catch (Exception ex)
+ catch
{
// ignore
}
// restore policy
+ ServicePointManager.CertificatePolicy = policy;
// service point
ServicePoint sp = request.ServicePoint;
if(sp == null) throw new Exception("sp is null for master "+ masterAddress);
if(sp.Certificate == null) throw new Exception("sp.Certificate is null for master "+masterAddress);
if ((sp != null) && (sp.Certificate != null))
- {
+ {
string path = Path.GetFullPath(Path.Combine(webPath, "web.config"));
string certRawDetail = Convert.ToBase64String(sp.Certificate.GetRawCertData());
- string certDetail = sp.Certificate.ToString(true);
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlElement cert = (XmlElement)doc.DocumentElement.SelectSingleNode("//configuration/appSettings/add[@key='SimiasCert']");
@@ -1622,9 +1635,7 @@
SearchPrpList.Add(BaseSchema.ObjectType, NodeTypes.MemberType, SearchOp.Equal);
SearchPrpList.Add(PropertyTags.Types, HostNode.HostNodeType, SearchOp.Equal);
ICSList searchList = domain.Search(SearchPrpList);
- DateTime t1= DateTime.Now;
SearchState searchState = new SearchState( domain.ID, searchList.GetEnumerator() as ICSEnumerator, searchList.Count );
- int total = searchList.Count;
int i = 0;
if(index > 0)
searchState.Enumerator.SetCursor(Simias.Storage.Provider.IndexOrigin.SET, index);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|