using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Threading;
using System.Xml;
using System.Xml.Serialization;
using EMC.Centera.SDK;
using EMC.Centera.FPTypes;
namespace AdrdProjectCentera1
{
public partial class frmMainForm : Form
{
string[] clusterAddress = new string[50];
public frmMainForm()
{
InitializeComponent();
//list of known cluster IPs and PEA files
clusterAddress[0] = "128.221.200.56?us1_profile1_rwqe.pea";
clusterAddress[1] = "128.221.200.56?us1_profile2_rwqedp.pea";
clusterAddress[2] = "128.221.200.56?us1_profile3_rwqedpD.pea";
clusterAddress[3] = "128.221.200.60?us2_profile1_rqecw.pea";
clusterAddress[4] = "128.221.200.60?us2_profile3_rdqeDcw.pea";
clusterAddress[5] = "128.221.200.60?us2_profile2_rdqecw.pea";
clusterAddress[6] = "128.221.200.64?us3_profile1_rqecw.pea";
clusterAddress[7] = "128.221.200.64?us3_profile3_rdqeDcw.pea";
clusterAddress[8] = "128.221.200.64?us3_profile2_rdqecw.pea";
clusterAddress[9] = "128.221.200.116?us4_profile1_rwqec.pea";
clusterAddress[10] = "128.221.200.116?us4_profile3_rwqecdD.pea";
clusterAddress[11] = "128.221.200.116?us4_profile2_rwqecd.pea";
clusterAddress[12] = "128.221.200.120?us5_profile1_rwqec.pea";
clusterAddress[13] = "128.221.200.120?us5_profile2_rwqecd.pea";
clusterAddress[14] = "128.221.200.120?us5_profile3_rwqecdD.pea";
clusterAddress[15] = "128.221.200.56";
clusterAddress[16] = "128.221.200.60";
clusterAddress[17] = "128.221.200.64";
clusterAddress[18] = "128.221.200.116";
clusterAddress[19] = "128.221.200.120";
clusterAddress[20] = "128.221.200.56, 128.221.200.57, 128.221.200.58, 128.221.200.59?us1_profile1_rwqe.pea";
clusterAddress[21] = "128.221.200.56, 128.221.200.57, 128.221.200.58, 128.221.200.59?us1_profile2_rwqedp.pea";
clusterAddress[22] = "128.221.200.56, 128.221.200.57, 128.221.200.58, 128.221.200.59?us1_profile3_rwqedpD.pea";
clusterAddress[23] = "128.221.200.60, 128.221.200.61, 128.221.200.62, 128.221.200.63?us2_profile1_rqecw.pea";
clusterAddress[24] = "128.221.200.60, 128.221.200.61, 128.221.200.62, 128.221.200.63?us2_profile3_rdqeDcw.pea";
clusterAddress[25] = "128.221.200.60, 128.221.200.61, 128.221.200.62, 128.221.200.63?us2_profile2_rdqecw.pea";
clusterAddress[26] = "128.221.200.64, 128.221.200.65, 128.221.200.66, 128.221.200.67?us3_profile1_rqecw.pea";
clusterAddress[27] = "128.221.200.64, 128.221.200.65, 128.221.200.66, 128.221.200.67?us3_profile3_rdqeDcw.pea";
clusterAddress[28] = "128.221.200.64, 128.221.200.65, 128.221.200.66, 128.221.200.67?us3_profile2_rdqecw.pea";
clusterAddress[29] = "128.221.200.116, 128.221.200.117, 128.221.200.118, 128.221.200.119?us4_profile1_rwqec.pea";
clusterAddress[30] = "128.221.200.116, 128.221.200.117, 128.221.200.118, 128.221.200.119?us4_profile3_rwqecdD.pea";
clusterAddress[31] = "128.221.200.116, 128.221.200.117, 128.221.200.118, 128.221.200.119?us4_profile2_rwqecd.pea";
clusterAddress[32] = "128.221.200.120, 128.221.200.121, 128.221.200.122, 128.221.200.123?us5_profile1_rwqec.pea";
clusterAddress[33] = "128.221.200.120, 128.221.200.121, 128.221.200.122, 128.221.200.123?us5_profile2_rwqecd.pea";
clusterAddress[34] = "128.221.200.120, 128.221.200.121, 128.221.200.122, 128.221.200.123?us5_profile3_rwqecdD.pea";
}
private void button1_Click(object sender, EventArgs e)
{
if (this.cmbPoolAddress.SelectedValue.ToString() == "")
{
//do nothing
}
else
{
GetCenteraPoolInfo(this.cmbPoolAddress.SelectedValue.ToString());
}
}
private void GetCenteraPoolInfo(string PoolID)
{
string strPoolInfo = "";
string strRetentionInfo = "";
AdrdCenteraClusterInfoItem ClusterItem = new AdrdCenteraClusterInfoItem();
AdrdCenteraRetentionInfoItem RetentionItem = new AdrdCenteraRetentionInfoItem();
// New in 3.1 - applications can be registered
FPPool.RegisterApplication("AdrdCenteraInformation", "3.1.477");
this.Cursor = Cursors.WaitCursor;
try
{
using (FPPool myPool = new FPPool(PoolID))
{
#region Populate Out Native class
ClusterItem.Blobnamingschemes = myPool.BlobNamingSchemes;
ClusterItem.Capacity = myPool.Capacity.ToString();
ClusterItem.Centeraedition = myPool.CenteraEdition;
ClusterItem.Centrastarversion = myPool.CentraStarVersion;
ClusterItem.Clipbuffersize = myPool.ClipBufferSize.ToString();
ClusterItem.Clusterid = myPool.ClusterID;
ClusterItem.Clustername = myPool.ClusterName;
ClusterItem.Deleteallowed = myPool.DeleteAllowed.ToString();
ClusterItem.Deletionslogged = myPool.DeletionsLogged.ToString();
ClusterItem.Existsallowed = myPool.ExistsAllowed.ToString();
ClusterItem.Freespace = myPool.FreeSpace.ToString();
ClusterItem.Queryallowed = myPool.QueryAllowed.ToString();
ClusterItem.Replicaaddress = myPool.ReplicaAddress;
ClusterItem.Retentiondefault = myPool.RetentionDefault.ToString();
ClusterItem.Sdkversion = FPPool.SDKVersion;
#endregion
#region These only apply to CenteraStart 3.1 and above
if (ClusterItem.Centrastarversion.Substring(0, 3) == "3.1")
{
//if (myPool.RetentionMinMax)
//{
RetentionItem.Fixedretentionmax = myPool.FixedRetentionMax.ToString();
RetentionItem.Fixedretentionmin = myPool.FixedRetentionMin.ToString();
RetentionItem.Retentiondefault = myPool.RetentionDefault.ToString();
RetentionItem.Variableretentionmax = myPool.VariableRetentionMax.ToString();
//}
}
else
{
RetentionItem = null;
}
#endregion
#region Build the String to display in the UI
strPoolInfo = ("\nPool Information" + "\n================" +
"\nCluster ID: " + myPool.ClusterID +
"\nCluster Time: " + myPool.ClusterTime +
"\nCluster Name: " + myPool.ClusterName +
"\nCentraStar software version: " + myPool.CentraStarVersion +
"\nSDK version: " + FPPool.SDKVersion +
"\nCluster Capacity (Bytes): " + myPool.Capacity +
"\nCluster Free Space (Bytes): " + myPool.FreeSpace +
"\nCluster BlobNamingSchemes : " + myPool.BlobNamingSchemes +
"\nCluster Capacity: " + myPool.Capacity.ToString() +
"\nCluster CenteraEdition: " + myPool.CenteraEdition +
"\nCluster ClipBufferSize: " + myPool.ClipBufferSize.ToString() +
"\nCluster DeleteAllowed: " + myPool.DeleteAllowed.ToString() +
"\nCluster DeletionsLogged: " + myPool.DeletionsLogged.ToString() +
"\nCluster ExistsAllowed: " + myPool.ExistsAllowed.ToString() +
"\nCluster QueryAllowed: " + myPool.QueryAllowed.ToString() +
"\nCluster RetentionDefault: " + myPool.RetentionDefault.ToString()+
"\nCluster ReadAllowed: " + myPool.ReadAllowed.ToString()+
"\nCluster WriteAllowed: " + myPool.WriteAllowed.ToString());
#endregion
#region Some Special Cases that the wrapper does not really handle well
try
{
strPoolInfo += ("\nCluster PoolProfiles: " + myPool.PoolProfiles);
}
catch (EMC.Centera.FPTypes.FPLibraryException eFP)
{
string typeofe = eFP.GetType().ToString();
strPoolInfo += ("\nCluster PoolProfiles: " + "Not Supported");
}
catch
{
strPoolInfo += ("\nCluster PoolProfiles: " + "Unknown Error");
}
try
{
strPoolInfo += ("\nCluster PoolMappings: " + myPool.PoolMappings);
}
catch (EMC.Centera.FPTypes.FPLibraryException eFP)
{
string typeofe = eFP.GetType().ToString();
strPoolInfo += ("\nCluster PoolMappings: " + "Not Supported");
}
catch
{
strPoolInfo += ("\nCluster PoolMappings: " + "Unknown Error");
}
#endregion
#region String the retention stuff for UI display
if (ClusterItem.Centrastarversion.Substring(0, 3) == "3.1" )
{
strPoolInfo += ("\nCluster EBRSupported: " + myPool.EBRSupported.ToString() +
"\nCluster HoldAllowed: " + myPool.HoldAllowed.ToString() +
"\nCluster HoldPools: " + myPool.HoldPools.ToString() +
"\nCluster Replica Address: " + myPool.ReplicaAddress);
// Print out the information on the Governors if we have Advanced Retention
if (myPool.RetentionMinMax)
{
strRetentionInfo = ("Variable Retention Min " + myPool.VariableRetentionMin +
"\nVariable Retention Max " + myPool.VariableRetentionMax +
"\nFixed Retention Min " + myPool.FixedRetentionMin +
"\nFixed Retention Max " + myPool.FixedRetentionMax +
"\nDefault Retention " + myPool.RetentionDefault);
}
}
#endregion
//write it to the UI
this.rtb.Text = strPoolInfo + "\n" + strRetentionInfo;
#region Save the Information
if (this.checkBox1.Checked == true)
{
this.Cursor = Cursors.WaitCursor;
Mutex mtx = new Mutex();
mtx.WaitOne();
{
if (File.Exists("Cstr_" + myPool.ClusterID.Trim() + ".xml"))
{
File.Delete("Cstr_" + myPool.ClusterID.Trim() + ".xml");
}
}
mtx.ReleaseMutex();
StreamWriter myClusterWriter = new StreamWriter("Cstr_"+ myPool.ClusterID.Trim ()+".xml");
XmlSerializer myClusterSerializer = new XmlSerializer(typeof(AdrdCenteraClusterInfoItem));
myClusterSerializer.Serialize(myClusterWriter, ClusterItem);
myClusterWriter.Close();
if (RetentionItem != null)
{
mtx.WaitOne();
{
if (File.Exists("Rtn_" + myPool.ClusterID.Trim() + ".xml"))
{
File.Delete("Rtn_" + myPool.ClusterID.Trim() + ".xml");
}
}
mtx.ReleaseMutex();
StreamWriter myRetWriter = new StreamWriter("Rtn_" + myPool.ClusterID.Trim() + ".xml");
XmlSerializer myRetSerializer = new XmlSerializer(typeof(AdrdCenteraRetentionInfoItem));
myRetSerializer.Serialize(myRetWriter, RetentionItem);
myRetWriter.Close();
}
this.lblSaved.Text = "Pool Information is Saved To : " + "Cstr_" + myPool.ClusterID.Trim() + ".xml\n";
if (RetentionItem != null)
{
this.lblSaved.Text += ("Retention Information is Saved To : " + "Rtn_" + myPool.ClusterID.Trim() + ".xml");
}
this.Cursor = Cursors.Default ;
}
#endregion
}
}
catch (EMC.Centera.FPTypes.FPLibraryException eExcep) //this exception is primamrly to catch the connection failure
{
string myExpetionMessage = eExcep.ToString();
if (myExpetionMessage.IndexOf ("error: -10020, error text: FP_NO_POOL_ERR")>-1)
{
this.Cursor = Cursors.Default;
throw new Exception("Could Not Connect To The Centera pool.\nPlease make sure that the appropriate ports are open.\nThis could be a result of a firewall restriction");
}
string strErrorInfo = eExcep.errorInfo.ToString();
}
catch (Exception e)
{
this.Cursor = Cursors.Default;
//do nothing
}
this.Cursor = Cursors.Default ;
}
private void Form1_Load(object sender, EventArgs e)
{
this.cmbPoolAddress.DataSource = clusterAddress;
this.cmbPoolAddress.SelectedIndex = 6; //I wanted to select a pool that is using the highest level of Centera Star, this happens to be US3
}
private void btnCancle_Click(object sender, EventArgs e)
{
this.Close();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.Checked == false)
this.lblSaved.Text = "";
}
}
}