Software Architecture – Design Problem Part 2 – DTO- MS Visual Studio 2010 – Net 4-0 – WCF – NHibernate – Silverlight

July 31, 2010

This is second post with reference to Design Architecture discussion on Project based on NHibernate + WCF+Sliverlight.
See the first Post last post here.

In my last post I had identified that we need DTO Objects.
DTO-Data Transfer Objects are customized object that can have different object structure then Objects used in OR Mapping/Nhibernate. When a request for object comes from client (Silverlight project) to server (ASP .Net project) having Service via WCF wire, at Server side, query is run on OR Mapping Object, utiizing full benefits of Lazy loading, business rules are applied, and finally data is ready to be send to client. At this point data is not in customized according to client needs and filtering of properties for objects is required to reduce the size of data being transferred. That where DTO objects comes in action.

Benefits of DTO objects:

1. It is always better from software design perspective to not expose object of data layer direct to client end that is silverlight via WCF.

2. Most important benefit is: filtering of object properties or Change in structure of objects that needs to be transferred across WCF wire. Let suppose you have invoice creation form having fields to be filled as like client, consignee, agent, shipper, sales person, operation manager and many other. So when loading invoice form data from all these entities like agents ……. will travel on WCF wire. Each entity may have a lot of properties, but on client side we only need id and name of all these entities. So we can make various versions of entities according to need for architecture.

3. With DTO approach, UI (silverlight) is only dependent on DTO objects, so the data layer can be changed to any tech like linq2sql,linq2entities or any other thing. Change in Data layer is very flexible with DTO.

Elements of Design Example:
You can download sample here.
Rename the file as sample.zip and then extract.

Solution Explorer will look like as:



This Example will fetch 2 different DTO objects with sample look and feel as below.


There is one entity class for nhibernate named as “Customer” with HBM set in Mapping.hbm.xml.

There are 2 DTO Classes. First DTO with properties as ClientID,ClientCode, Name.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;

namespace WCFNHibernateSilverLightSample.Web.DTOEntities
{
    [DataContract(IsReference = true)] 
    public class DTOCustomer
    {
        #region Fields
        private int _ClientID;
        private string _ClientCode;
        private string _Name;
        #endregion
        #region Constructors
        /// <summary>
        /// Initializes a new instance of the GeneralClientMaster class 
        /// </summary> 
        public DTOCustomer()
        {
        }     
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the ClientID for the current GeneralClientMaster
        /// </summary>
        [DataMember]
        public virtual int ClientID
        {
            get { return _ClientID; }
            set { _ClientID = value; }
        }

        /// <summary>
        /// Gets or sets the ClientCode for the current GeneralClientMaster
        /// </summary>
        [DataMember]
        public virtual string ClientCode
        {
            get { return _ClientCode; }
            set { _ClientCode = value; }
        }
        [DataMember]
        public virtual string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        #endregion

    }

    
}

Second DTO class has extra parameter of Address as:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;

namespace WCFNHibernateSilverLightSample.Web.DTOEntities
{
    [DataContract(IsReference = true)]
    public class DTOCustomerVersionWithAddress
    {
        #region Fields
        private int _ClientID;
        private string _ClientCode;
        private string _Name;
        private string _Address;
        #endregion
        #region Constructors
        /// <summary>
        /// Initializes a new instance of the GeneralClientMaster class 
        /// </summary> 
        public DTOCustomerVersionWithAddress()
        {
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the ClientID for the current GeneralClientMaster
        /// </summary>
        [DataMember]
        public virtual int ClientID
        {
            get { return _ClientID; }
            set { _ClientID = value; }
        }

        /// <summary>
        /// Gets or sets the ClientCode for the current GeneralClientMaster
        /// </summary>
        [DataMember]
        public virtual string ClientCode
        {
            get { return _ClientCode; }
            set { _ClientCode = value; }
        }
        [DataMember]
        public virtual string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        [DataMember]
        public virtual string Address
        {
            get { return _Address; }
            set { _Address = value; }
        }

        #endregion

    }
 
}

A converter class will be required as below to transform “customer” to “DTOCustomer” and “DTOCustomerVersionWithAddress”.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WCFNHibernateSilverLightSample.Web.DTOEntities.DTOConvertor
{
    public class DTOConvertor
    {
        #region CustomerConvertor

        public static DTOCustomer ConvertFromCustomerToDTOCustomer(Customer cust)
        {
            DTOCustomer dtocus = new DTOCustomer();
            dtocus.ClientID =  cust.ClientID;
            dtocus.ClientCode =  cust.ClientCode;
            dtocus.Name =  cust.Name;            
            return dtocus;            
        }
        public static DTOCustomerVersionWithAddress ConvertFromCustomerToDTOCustomerVersionWithAddress(Customer cust)
        {
            DTOCustomerVersionWithAddress dtocus = new DTOCustomerVersionWithAddress();
            dtocus.ClientID = cust.ClientID;
            dtocus.ClientCode = cust.ClientCode;
            dtocus.Name = cust.Name;
            // Note here Transformation of properties from Nhibernate Object to DTO Objects
            // It is really a simple example. Very advance level tranformation can be done.
            dtocus.Address = cust.PostalAddress + " Tel: " + cust.Phone1 + " Fax: " + cust.Fax1 + " Email : " + cust.Email;
            return dtocus;
        }
        #endregion CustomerConvertor
    }
}

The WCF Service code will look like as

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Channels;
using NHibernate;
using WCFNHibernateSilverLightSample.Web.DTOEntities;
using WCFNHibernateSilverLightSample.Web.DTOEntities.DTOConvertor;

namespace WCFNHibernateSilverLightSample.Web
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "GetDataService" in code, svc and config file together.
    public class GetDataService : IGetDataService
    {
        public IList<DTOCustomer> GetCustomer()
        {
            IList<Customer> list;
            IList<DTOCustomer> listDTO =  new List<DTOCustomer>();
            NHibernate.ISession session = NHibernateHelper.OpenSession();
            ICriteria query = session.CreateCriteria(typeof(Customer));
            list = query.List<Customer>();

            foreach(Customer c in list)
            {
                listDTO.Add(DTOConvertor.ConvertFromCustomerToDTOCustomer(c));
            }
            return listDTO;
        }
        public IList<DTOCustomerVersionWithAddress> GetCustomerWithAddress()
        {
            IList<Customer> list;
            IList<DTOCustomerVersionWithAddress> listDTO = new List<DTOCustomerVersionWithAddress>();
            NHibernate.ISession session = NHibernateHelper.OpenSession();
            ICriteria query = session.CreateCriteria(typeof(Customer));
            list = query.List<Customer>();

            foreach (Customer c in list)
            {
                listDTO.Add(DTOConvertor.ConvertFromCustomerToDTOCustomerVersionWithAddress(c));
            }
            return listDTO;
        }
    }
}

You can download sample here.
Rename the file as sample.zip and then extract.


Software Architecture – Problems and Solutions with MVVM Model-View-ViewModel

July 29, 2010

MSDN Flash Newsletter pointed out a very good article dated July 19, 2010 .

Topic: When is the MVVM design pattern applicable to RIA and desktop apps? When is it unnecessary?
By: Robert McCarter
URL: http://msdn.microsoft.com/en-us/magazine/ff798279.aspx

Really a good Reading.


Software Architecture – Isolated Storage Introduction

July 29, 2010

Silverlight application works on client end browser, after downloading from web server.
Silverlight provide isolated storage which provides file system based storage space for storing the data on client side.

Isolated storage can act like cookies in ASP .Net, so used in saving session related data about session and application state. Secondly media data like video/audio files can be saved on client end, for second time fast access and manipulation.

On silverlight page, right click to see the configuration screen for isolated storage as:


Sample Code

Lets follow a simple application for reading and writing to isolated storage which will look like as:


Code to save data will look like as:

            using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("data.txt", FileMode.Create, isoStore))
                {
                    using (StreamWriter writer = new StreamWriter(isoStream))
                    {
                        writer.Write(datatowrite.Text);
                    }
                }

            }

Code to read data will look like as:

using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream isoStream =
                    new IsolatedStorageFileStream("data.txt", FileMode.OpenOrCreate, isoFile))
                {
                    using (StreamReader sr = new StreamReader(isoStream))
                    {
                        dataread.Text = sr.ReadToEnd();
                    }
                }

Reference:
www.silverlight.net


Software Architecture – Microsoft SQL Server Express Edition with Advance Features -Licensing Query

July 29, 2010

While Exploring Licensing option for PCMS ERP Pegasus Cargo Management System, i had passed a query to Microsoft-Pakistan.

My Query to Microsoft Licensing Team – Islamabad – Pakistan

We are evaluating to use Microsoft SQL Server Express edition with advance features for our product.

With reference to your link below,
http://msdn.microsoft.com/en-us/library/cc645993.aspx
We have some questions as:

1. Is there any limitation of number of clients connecting to SQL Server express edition with advance features?

2. Secondly, table with title as “Scalability and Performance” in the above link suggests that there is a limitation of “Maximum memory utilized” as “1 GB” for SQL Server Express edition with advance features.. What is the meaning of this limitation, can you please explain it in more detail? Does this memory refer to the size of memory that can be used in system where SQL server will be installed or it is the memory being used by SQL server process in task manager of OS.


Is there any limitation of number of clients connecting to SQL Server express edition with advance features?

Microsoft Answer:- Yes, generally SQL Server allows 32,767 concurrent / simultaneous connections, however for your instance you can check by running the @@MAX_CONNECTIONS function. This function would return you the maximum number of connections on that particular instance, however it can be different from the currently configured maximum number of connections on that particular instance so this is configurable (sp_configure) but staying within the maximum connection limit.

Secondly, table with title as “Scalability and Performance” in the above link suggests that there is a limitation of “Maximum memory utilized” as “1 GB” for SQL Server Express edition with advance features.. What is the meaning of this limitation, can you please explain it in more detail? Does this memory refer to the size of memory that can be used in system where SQL server will be installed or it is the memory being used by SQL server process in task manager of OS.

Microsoft Answer:- This is the maximum memory which SQL Server express can use, regardless of the system memory.


Software Architecture – Design Problem – MS Visual Studio 2010 + .Net 4.0 + WCF + NHibernate + Silverlight

July 28, 2010

Environment: MS Visual Studio 2010 + .Net 4.0 + WCF + NHibernate + Silverlight

This post assumes that you have initial knowledge of WCF, NHibernate, Silverlight.

See the sample code for this solution working here.
Rename file as up.zip for extracting.

Sample Project:

Entities Relation / Tables relation is like:

Region >> Country >> City >> Area

So each region has many countries, Each country has many cities. Each City has many regions.
A typical Silverlight solution is created with 2 projects (One for silverlight(Client side project), other for ASP .Net Web project (server side ) having a WCF Service for data transfer from server side to client side.

Problem Definition:

Lets suppose you want to get list of City with lazy=”false” and fetch=”join”
for all entities So we will get following queries in SQL Profiler:

SELECT this_.CityID as CityID3_2_, this_.CountryID as CountryID3_2_, this_.CityCode as CityCode3_2_, this_.Description as Descript4_3_2_, this_.Active as Active3_2_, country2_.CountryID as CountryID1_0_, country2_.CountryCode as CountryC2_1_0_, country2_.Description as Descript3_1_0_, country2_.Active as Active1_0_, country2_.RegionId as RegionId1_0_, regions3_.RegionID as RegionID0_1_, regions3_.RegionCode as RegionCode0_1_, regions3_.Description as Descript3_0_1_, regions3_.Active as Active0_1_ FROM GeneralCityMaster this_ left outer join GeneralCountryMaster country2_ on this_.CountryID=country2_.CountryID left outer join GeneralRegionMaster regions3_ on country2_.RegionId=regions3_.RegionID

Again get list of City with lazy=”false” and fetch=”select”
for all entities So we will get following queries in SQL Profiler:

SELECT this_.CityID as CityID3_0_, this_.CountryID as CountryID3_0_, this_.CityCode as CityCode3_0_, this_.Description as Descript4_3_0_, this_.Active as Active3_0_ FROM GeneralCityMaster this_

For each country in list, there will be an select from country table as:

exec sp_executesql N'SELECT country0_.CountryID as CountryID1_0_, country0_.CountryCode as CountryC2_1_0_, country0_.Description as Descript3_1_0_, country0_.Active as Active1_0_, country0_.RegionId as RegionId1_0_ FROM GeneralCountryMaster country0_ WHERE country0_.CountryID=@p0',N'@p0 int',@p0=1

For each region in list, there will be an select from region table as:

exec sp_executesql N'SELECT regions0_.RegionID as RegionID0_0_, regions0_.RegionCode as RegionCode0_0_, regions0_.Description as Descript3_0_0_, regions0_.Active as Active0_0_ FROM GeneralRegionMaster regions0_ WHERE regions0_.RegionID=@p0',N'@p0 int',@p0=21

Two Problems:
There are 2 problems with above implementation.

Lazy load is false, so on server side that is ASP .Net / WCF Project, if we need some processing to be done, it is loading all data, no lazy initialization helps us.

Secondly, in both above cases data is joined from all the corresponding tables even if it is not required. Suppose we want to get data of cities only but unfortunately data of country and region is also fetched and transfer of such a heavy data across the WCF wire is very heavy activity.

If you will change lazy=”true” for entities, then WCF will pass following error.

{System.Net.WebException: The remote server returned an error: NotFound.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)}

In order to see the real problem, configure WCF Log as explained
as explained at here

On looking into



Exeption will look like as:

There was an error while trying to serialize parameter http://tempuri.org/:GetCitiesResult. The InnerException message was 'Type 'CountryProxy' with data contract name 'CountryProxy:http://schemas.datacontract.org/2004/07/' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

Stack trace will look like as:

System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameter(XmlDictionaryWriter writer, PartInfo part, Object graph)
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)
System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
System.ServiceModel.Channels.BodyWriterMessage.OnBodyToString(XmlDictionaryWriter writer)
System.ServiceModel.Channels.Message.ToString(XmlDictionaryWriter writer)
System.ServiceModel.Diagnostics.MessageLogTraceRecord.WriteTo(XmlWriter writer)
System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLogTraceRecord record)
System.ServiceModel.Diagnostics.MessageLogger.LogMessageImpl(Message&amp; message, XmlReader reader, MessageLoggingSource source)
System.ServiceModel.Diagnostics.MessageLogger.LogMessage(Message&amp; message, XmlReader reader, MessageLoggingSource source)
System.ServiceModel.Dispatcher.DispatchOperationRuntime.SerializeOutputs(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)
System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
System.Runtime.InputQueue`1.AsyncQueueReader.Set(Item item)
System.Runtime.InputQueue`1.EnqueueAndDispatch(Item item, Boolean canDispatchOnThisThread)
System.Runtime.InputQueue`1.EnqueueAndDispatch(T item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.SingletonChannelAcceptor`3.Enqueue(QueueItemType item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

This exception reflects that when WCF serializer tries to load countries, it fails because of lazy loading being true as country will be a proxy object, so it will pass the exception.

Solution:
After reviewing the suggestions provided by Sowmy Srinivasan’s Blog at:
http://blogs.msdn.com/b/sowmy/archive/2006/03/26/561188.aspx

and discussion on Johan Danforth’s Blog at:
http://weblogs.asp.net/jdanforth/archive/2008/12/22/nhibernate-and-wcf-is-not-a-perfect-match.aspx

I have introduced 3 new classes as:

1. HibernateDataContractSurrogate which implements IDataContractSurrogate which replaces proxy object with forcefully created object by the DataContractSerializer of WCF during serialization.

MSDN Reference:
http://msdn.microsoft.com/en-us/library/ms574969.aspx

2. ReferencePreservingDataContractSerializerOperationBehavior
Which is derived from DataContractSerializerOperationBehavior will extend the functionality provided by DataContract behavior.

3. ReferencePreservingDataContractFormatAttribute which provide attribute that will apply the behavior created above with name
ReferencePreservingDataContractSerializerOperationBehavior

So in short we have modified the behavior of data contract by using IDataContractSurrogate to replace proxy object with forcefully created object.

After this above change of introducing 3 classes, old exception of countryproxy will disappear, but a new exception will be there as below.

There was an error while trying to serialize parameter http://tempuri.org/:GetCitiesResult. The InnerException message was 'Type 'WCFNHibernateSilverLightSample.Web.City' with data contract name 'City:http://schemas.datacontract.org/2004/07/WCFNHibernateSilverLightSample.Web' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

Trace as:

System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameter(XmlDictionaryWriter writer, PartInfo part, Object graph)
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)
System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
System.ServiceModel.Channels.BodyWriterMessage.OnBodyToString(XmlDictionaryWriter writer)
System.ServiceModel.Channels.Message.ToString(XmlDictionaryWriter writer)
System.ServiceModel.Diagnostics.MessageLogTraceRecord.WriteTo(XmlWriter writer)
System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLogTraceRecord record)
System.ServiceModel.Diagnostics.MessageLogger.LogMessageImpl(Message&amp; message, XmlReader reader, MessageLoggingSource source)
System.ServiceModel.Diagnostics.MessageLogger.LogMessage(Message&amp; message, XmlReader reader, MessageLoggingSource source)
System.ServiceModel.Dispatcher.DispatchOperationRuntime.SerializeOutputs(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)
System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
System.Runtime.InputQueue`1.AsyncQueueReader.Set(Item item)
System.Runtime.InputQueue`1.EnqueueAndDispatch(Item item, Boolean canDispatchOnThisThread)
System.Runtime.InputQueue`1.EnqueueAndDispatch(T item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.SingletonChannelAcceptor`3.Enqueue(QueueItemType item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Solution for the above exception is provided at:
http://msdn.microsoft.com/en-us/library/system.servicemodel.serviceknowntypeattribute.aspx

Introduce ServiceKnownType attribute in service contract with a helper class,
So the Service will look like as:

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IGetDataService" in both code and config file together.
    [ServiceContract]
    [ServiceKnownType("GetKnownTypes", typeof(Helper))]
    public interface IGetDataService
    {

        [OperationContract]        
        [ReferencePreservingDataContractFormat]
        IList<City> GetCities();
    }



// This class has the method named GetKnownTypes that returns a generic IEnumerable.
    static class Helper
    {
        public static IEnumerable<Type> GetKnownTypes(ICustomAttributeProvider provider)
        {
            System.Collections.Generic.List<System.Type> knownTypes =
                new System.Collections.Generic.List<System.Type>();
            // Add any types to include here.
            knownTypes.Add(typeof(City));
            knownTypes.Add(typeof(Country));
            knownTypes.Add(typeof(Regions));
            knownTypes.Add(typeof(AreaMaster));
            
            return knownTypes;
        }
    }

So now the first problem has been solved. So now in business classes we can use objects with lazy loading working, only required object will be initialized. We have lazy loading true in OR Mapping, so on Server side “WCFNHibernateSilverLightSample.Web” project will access the object model with fully operational benefits of lazy loading.

See the sample code for this solution working here.

But second problem still exists. To solve the second problem, DTO (Data Transfer Objects) are used. DTO object are simple entity objects have the only those properties that needs to be transferred via WCF wire, So OR Mapping Nhibernate object will be different from DTO objects. Once the data is fetched in OR Mapping Nhibernate object, a transformation is done to DTO object and light weight DTO objects are passed with WCF to client end silverlight project.

I will do one more post to demonstrate this second problem in next post.

Both problems must be solved in a Good designed WCF/Sliverlight/Nhibernate project.

Happy Coding.


Software Architecture – C# 4.0- New Feature – Named Parameters and Optional Parameters

July 25, 2010

C# 4.0 introduced two new concepts as Named Parameters and Optional Parameters

Named Parameters:

Named arguments enable you to specify an argument for a particular parameter by associating the argument with the parameter’s name rather than with the parameter’s position in the parameter list.

Example:

public int CalculateSize(int Lenght , int Width ,  int Height)       
{        return Lenght + Width + Height;
 }

Can be called as

CalculateSize(1, 2, 2);            // call without named parameters
CalculateSize(Lenght:3, Height: 3, Width: 3);
CalculateSize(2, Height: 3, Width: 3); // A unnamed parameter can follow named parameter in argument list
CalculateSize(Lenght:3, Height: 3, 3); // Error: A named parameter can't follow unnamed parameters  in argument list

IntelliSense is shown for named parameters as shown below by specifying parameters name followed by “:”

Optional Parameters:
The definition of a method, constructor, indexer, or delegate can specify that its parameters are required or that they are optional. Any call must provide arguments for all required parameters, but can omit arguments for optional parameters.
Each optional parameter has a default value as part of its definition. If no argument is sent for that parameter, the default value is used. Default values must be constants.
Optional parameters are defined at the end of the parameter list, after any required parameters. If the caller provides an argument for any one of a succession of optional parameters, it must provide arguments for all preceding optional parameters

public int CalculateSize(int Lenght , int Width ,  int Height = 6)
        {
         return Lenght + Width + Height;
       }

Here “Height” is Optional parameter because it default value is specified.

CalculateSize(3, 5); // Height is optional parameter,so can be skipped.
CalculateSize(3, , 5); //  Error: Width is not optional parameter,so can't be skipped
CalculateSize(3);   //Error: Invalid parameters

Optional parameters are shown by square brackets


Software Architecture – What is future of Web with reference to HTML 5-Will it devalue current presentation layer technologies for Web like Flash, Silverlight

July 25, 2010

 
A Cross Referenced Note about HTML5

                                                                     By: Shahzad Sarwar

                                                                     To: Development Team

                                                                     Dated: 25th July 2010

Scope:

What is HTML5?

What are the new features in HTML5?

What is future of Web with reference to HTM 5-Will it devalue current presentation layer technologies for Web like Flash, Silverlight?

What is HTML5?

HTML5 is currently under development as the next major revision of the HTML standard. Like its immediate predecessors, HTML 4.01 and XHTML 1.1, HTML5 is a standard for structuring and presenting content on the World Wide Web. The new standard incorporates features like video playback and drag-and-drop that have been previously dependent on third-party browser plug-ins such as Adobe Flash, Microsoft Silverlight, and Google Gears.

The Web Hypertext Application Technology Working Group (WHATWG) started work on the specification in June 2004 under the name Web Applications 1.0. As of March 2010[update], the specification is in the Draft Standard state at the WHATWG, and in Working Draft state at the W3C. Ian Hickson of Google, Inc. is the editor of HTML5.

Ian Hickson, editor of the HTML5 specification, expects the specification to reach the Candidate Recommendation stage during 2012. The criteria for the specification becoming a W3C Recommendation is “two 100% complete and fully interoperable implementations”. In an interview with TechRepublic, Hickson guessed that this would occur in the year 2022 or later. However, many parts of the specification are stable and may be implemented in products.

What are new Features in HTML5?

In addition to specifying markup, HTML5 specifies scripting application programming interfaces (APIs). Existing document object model (DOM) interfaces are extended and de facto features documented. There are also new APIs, such as:

For more details about new features see these videos by Google.

What is future of Web with reference to HTM 5-Will it devalue current presentation layer technologies for Web like Flash, Silverlight?

Answer is No. Because the features that HTML5 is providing is very small subset of the functionality provided by Flash and Silverlight.

Lets take an example of 2D/3D Graphics support. Although HTML5 has provided Canvas API but it can’t be compared with full support provided by Silverlight or Flash.

Same is the case with Video and Audio support. HTML before HTML5 don’t have audio and video support. Now that support is there in HTML5. But this support is limited and can’t help in all cases.

So in short yes, with HTML5, the standard has grown a lot and there will always space for commercial products who will enhance the standard and will provide more deep implementation of features.

This gap between standard and commercialization of standard in products will always be there.

Wait till all features of HTML5 are implemented in all browsers and enjoy the new world of web.

References:

http://www.youtube.com/watch?v=EdDc7sWjCL4&NR=1

http://www.youtube.com/watch?v=siOHh0uzcuY&feature=channel

http://www.youtube.com/watch?v=aW–Wlf9EFs&feature=channel

http://www.youtube.com/watch?v=AusOPz8Ww80&feature=related

http://dev.w3.org/html5/spec/Overview.html

http://dev.w3.org/html5/html4-differences/


Software Architecture – Interview Questions for Windows Communication Foundation-WCF Architect

July 23, 2010

Let suppose you are invited for an interview as Windows Communication Foundation-WCF Architect.

WCF is a very hard topic to handle. It is very hard to cover all features of WCF in detail, but I have compiled few questions from MSDN related to such interview.

Enjoy……and Best of luck for interview…:)

——————————————————————————————————-

What is Endpoints?

Endpoints provide clients access to the functionality offered by a WCF service.

Each endpoint consists of four properties:

  • An address that indicates where the endpoint can be found.
  • A binding that specifies how a client can communicate with the endpoint.
  • A contract that identifies the operations available.
  • A set of behaviors that specify local implementation details of the endpoint.

 

What is Endpoint Address?

The address uniquely identifies the endpoint and tells potential consumers of the service where it is located. It is represented in the WCF object model by the EndpointAddress class. An EndpointAddress class contains:

  • A Uri property, which represents the address of the service.
  • An Identity property, which represents the security identity of the service and a collection of optional message headers. The optional message headers are used to provide additional and more detailed addressing information to identify or interact with the endpoint.

 

What is Endpoints Binding?

Binding: The binding specifies how to communicate with the endpoint. This includes:

  • The transport protocol to use (for example, TCP or HTTP).
  • The encoding to use for the messages (for example, text or binary).
  • The necessary security requirements (for example, SSL or SOAP message security).

 

What is Endpoints Contracts?

The contract outlines what functionality the endpoint exposes to the client. A contract specifies:

  • What operations can be called by a client.
  • The form of the message.
  • The type of input parameters or data required to call the operation.
  • What type of processing or response message the client can expect.

 

What is Endpoints  Behaviors?

Behaviors: You can use endpoint behaviors to customize the local behavior of the service endpoint. Endpoint behaviors achieve this by participating in the process of building a WCF runtime.

What are different system provided system bindings?

  • BasicHttpBinding
  • WSHttpBinding
  • WS2007HttpBinding
  • WSDualHttpBinding
  • WSFederationHttpBinding
  • WS2007FederationHttpBinding
  • NetTcpBinding
  • NetNamedPipeBinding
  • NetMsmqBinding
  • NetPeerTcpBinding
  • MsmqIntegrationBinding

 

What is difference between Service Binding and Client Binding?

What are different ways to define binding?

Two ways as:

  • Via Configuration file
  • Via Code

 

What is difference b/w System-Provided Bindings ,  Custom Bindings and Creating User-Defined Bindings?

What is Service Contract?

A service contract is a statement that provides information about:

  • The grouping of operations in a service.
  • The signature of the operations in terms of messages exchanged.
  • The data types of these messages.
  • The location of the operations.
  • The specific protocols and serialization formats that are used to support successful communication with the service.

What are different Contract types?

Different types of message-exchange patterns (MEPs) that contracts are as:

  • Request-reply
  • One-way
  • Duplex.

 

What are Request-Reply Services?

Clients make calls (Request) to service operations and wait for a response from the service.

Calls to a service operation either synchronously or asynchronously.

Default type Service Contract Operation.

Example for Service Contract ?

using System.ServiceModel;

[ServiceContract]

public interface ICalculator

{

[OperationContract]

// It would be equivalent to write explicitely:

// [OperationContract(IsOneWay=false)]

int Add(int a, int b);

[OperationContract]

int Subtract(int a, int b);

int Multiply(int a, int b)

}

What are One-Way Services?

With a one-way operation, only one message is transmitted. The receiver does not send a reply message, nor does the sender expect one.

[OperationContract(IsOneWay=true)]

    void Add(double n1, double n2);

What is A duplex service contract?

A duplex service contract is a message exchange pattern in which both endpoints can send messages to the other independently.

Duplex communication occurs when a client connects to a service and provides the service with a channel on which the service can send messages back to the client.

[ServiceContract(Namespace = “http://Microsoft.ServiceModel.Samples&#8221;, SessionMode=SessionMode.Required,                 CallbackContract=typeof(ICalculatorDuplexCallback))]

public interface ICalculatorDuplex

{

    [OperationContract(IsOneWay = true)]

    void Clear();

    [OperationContract(IsOneWay = true)]

    void AddTo(double n);

}

public interface ICalculatorDuplexCallback

{

    [OperationContract(IsOneWay = true)]

    void Equals(double result);

    [OperationContract(IsOneWay = true)]

    void Equation(string eqn);

}

In constructor of service contract implementation as:

ICalculatorDuplexCallback callback = null;

and

callback = OperationContext.Current.GetCallbackChannel<ICalculatorDuplexCallback>();

and

public void AddTo(double n)

  {

        result += n;

        equation += ” + ” + n.ToString();

        callback.Equals(result);

  }

Define session, Instancing and Concurrency for WCF?

A session is a correlation of all messages sent between two endpoints.

Instancing refers to controlling the lifetime of user-defined service objects and their related T:System.ServiceModel.InstanceContext objects.

Concurrency is the term given to the control of the number of threads executing in an InstanceContext at the same time.

What are the mode of instancing in WCF?

  • PerCall: A new InstanceContext (and therefore service object) is created for each client request.
  • PerSession: A new InstanceContext (and therefore service object) is created for each new client session and maintained for the lifetime of that session (this requires a binding that supports sessions).
  • Single: A single InstanceContext (and therefore service object) handles all client requests for the lifetime of the application.

 

What is SessionMode in WCF?

System.ServiceModel.SessionMode enumeration to specify whether the contract:

  • Requires a session.
  • Allows a client to establish a session.
  • Prohibits a session.

 

What are the concurrency modes?

  • Single: Each instance context is allowed to have a maximum of one thread processing messages in the instance context at a time. Other threads wishing to use the same instance context must block until the original thread exits the instance context.
  • Multiple: Each service instance can have multiple threads processing messages concurrently. The service implementation must be thread-safe to use this concurrency mode.
  • Reentrant: Each service instance processes one message at a time, but accepts re-entrant operation calls. The service only accepts these calls when it is calling out through a WCF client object.

 

What are different Transport in WCF?

HTTP, TCP, and named pipes. WCF also includes a message queuing (also known as MSMQ) transport.

When to Use HTTP Transport in WCF?

When to Use the TCP Transport in WCF?

When to Use the Named Pipe Transport in WCF?

What are Decision Points for Choosing a Transport, Explain each?

  • Diagnostics
  • Hosting
  • Inspection
  • Latency
  • Reach
  • Security
  • Throughput
  • Tooling

 

What is Message Encoder and what are different options for message encoders in WCF?

Binary, Text, and Message Transmission Optimization Mechanism (MTOM).

How to Choose a Message Encoder in WCF, explain each?

  • Inspection
  • Reliability
  • Simplicity
  • Size
  • Streaming
  • 3rd Party Tool Support
  • Interoperability

 

What are different message transfer modes?

  • Buffered transfers hold the entire message in a memory buffer until the transfer is complete. A buffered message must be completely delivered before a receiver can read it.
  • Streamed transfers expose the message as a stream. The receiver starts processing the message before it is completely delivered.

The binding element has a TransferMode property that can be set to Buffered, Streamed, StreamedRequest, or StreamedResponse.

What are different Hosting options for WCF Service?

A service can be hosted by Internet Information Services (IIS), Windows Process Activation Service (WAS), a Windows service, or by a managed application—this option is often referred to as self hosting”.

Differentiate b/w service contract, operation contract, message contract, fault contract and data contract?

Service contract

The service contract ties together multiple related operations into a single functional unit. The contract can define service-level settings, such as the namespace of the service, a corresponding callback contract, and other such settings. In most cases, the contract is defined by creating an interface in the programming language of your choice and applying the ServiceContractAttribute attribute to the interface. The actual service code results by implementing the interface.

Operation contract

An operation contract defines the parameters and return type of an operation. When creating an interface that defines the service contract, you signify an operation contract by applying the OperationContractAttribute attribute to each method definition that is part of the contract. The operations can be modeled as taking a single message and returning a single message, or as taking a set of types and returning a type. In the latter case, the system will determine the format for the messages that need to be exchanged for that operation.

Message contract

A message contract describes the format of a message. For example, it declares whether message elements should go in headers versus the body, what level of security should be applied to what elements of the message, and so on.

Fault contract

A fault contract can be associated with a service operation to denote errors that can be returned to the caller. An operation can have zero or more faults associated with it. These errors are SOAP faults that are modeled as exceptions in the programming model.

Data contract

The data types a service uses must be described in metadata to enable others to interoperate with the service. The descriptions of the data types are known as the data contract, and the types can be used in any part of a message, for example, as parameters or return types. If the service is using only simple types, there is no need to explicitly use data contracts.

What is Reliable Sessions?

A reliable session implements the WS-ReliableMessaging protocol and an in-memory transfer window to mask SOAP message-level failures and re-establishes connections in the case of transport failures.

Which Bindings support reliable Session?

The system-defined bindings that support and enable a reliable session by default include:

  • WSDualHttpBinding

The system-provided bindings that support a reliable session as an option but do not enable one by default include:

  • WSHttpBinding
  • WSFederationHttpBinding
  • NetTcpBinding

 

When to use reliable Session?

  • SOAP intermediaries, such as SOAP routers.
  • Proxy intermediaries or transport bridges.
  • Intermittent connectivity.
  • Sessions over HTTP.

 

Identify few business cases for Queue implementation in WCF?

Explain MSMQ implementation in WCF?

What is Dead-Letter Queue Programming?

What is Poison Message Queue Programming?

 

How Transactions are implemented in WCF?

WCF implements support for the WS-AtomicTransaction (WS-AT) protocol that enables WCF applications to flow transactions to interoperable applications, such as interoperable Web services built using third-party technology. WCF also implements support for the OLE Transactions protocol, which can be used in scenarios where you do not need interop functionality to enable transaction flow.

What is MSDTC?

The Microsoft Distributed Transaction Coordinator (MSDTC) is a transaction manager that provides support for distributed transactions.

 

How to specify ServiceModel Transaction Attributes?

Three standard System.ServiceModel attributes that enable you to configure the behavior of transactions for a WCF service:

  • TransactionFlowAttribute
  • ServiceBehaviorAttribute
  • OperationBehaviorAttribute

 

How to specify ServiceModel Transaction details in Configuration?

Provides three attributes for configuring transactions for a service: transactionFlow ( in binding configuration), transactionProtocol( in binding configuration), and transactionTimeout(in the behavior element of the configuration file).

What Controls Transaction Settings in WCF?

Transaction flow settings are generated for a service endpoint as a result of the intersection of the following three values:

  • The TransactionFlowAttribute attribute specified for each method in the service contract.
  • The TransactionFlow binding property in the specific binding.
  • The TransactionFlowProtocol binding property in the specific binding.

 

What is usage of wsatConfig.exe?

wsatConfig.exe is used to configure WS-AT settings.

 

Define followings:

  • WS-*
  • WCF client
  • transport with message credential security mode
  • transport security mode
  • terminating operation
  • system-provided bindings
  • service operation
  • service contract
  • service
  • self-hosted service
  • security
  • operation contract
  • metadata
  • message security mode
  • message contract
  • message
  • instancing model
  • initiating operation
  • hosting process
  • hosting
  • fault contract
  • endpoint
  • data contract
  • contract
  • channel
  • binding element
  • binding
  • behavior
  • application endpoint
  • address

Software Architecture – To Analyze Licensing needs for PCMS- Pegasus Cargo Management System

July 19, 2010

Topic: To Analyze Licensing needs for PCMS- Pegasus Cargo Management System
By: Shahzad Sarwar
Dated: 19th July 2010

Pegasus Cargo Management System-PCMS:
Pegasus Cargo Management System is one of the FIRST software in the cargo industry, which is totally integrated with accounts. Designed by experts from cargo and software industry it provides one stop solution for data entry and decision support. The implementation of detailed function level checks ensures reliability & date integrity of system. The embedded security through appropriate Access Controls allows complete control of user access and data manipulation. PCMS provides detailed and extensive MIS reports helping the management to take informed decisions.

Conclusions:
• PCMS-Pegasus Cargo Management System needs .Net framework 3.5 runtime and SQL server on a Windows Machine.
• Microsoft .Net 3.5 runtime is shipped free on all latest windows version. If not available , it can be installed by downloading from Microsoft site for free.
• PCMS-Pegasus Cargo Management System is targeted for small to medium size organizations where database needs are not very high tech. Advance features of SQL Server are not required for application to run.
• With reference to section 2.1, most close versions for consideration should be SQL Server Express edition and SQL Server Workgroup Edition.
• SQL Server Express edition with advance features will be launching pad for PCMS ERP. As it is free and have all the features required to run PCMS.
• For Details about SQL Server Express edition with Advance features, see tables (2.2, 2.3).
• After starting along SQL Server Express edition with Advance features, down the roads, when database size exceeds 10 GB limit, we can propose clients to switch to SQL Server Workgroup edition.
• For detailed analysis of SQL Server Express edition with advance features, see section (3.1, 3.2, 3.3, 3.4, 3.5, 3.6) in Red Color.
• For detailed analysis of SQL Server Workgroup edition, see sections (3.1, 3.2, 3.3, 3.4, 3.5, 3.6) in Pink Color.
• Pricing for licenses shown in section 4.


Software Architecture – A Cross Referenced Whitepaper on Cloud Computing

July 14, 2010

 

A Cross Referenced Whitepaper on Cloud Computing

                                                     By: Shahzad Sarwar

                                                     Dated: 14th July 2010

 

 

1           Definition:

According to wiki:

Cloud Computing is Internet-based computing, whereby shared resources, software, and information are provided to computers and other devices on demand, like the electricity grid.

According to National Institute of Standards and Technology:

Cloud computing is a model for enabling convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, and services) that can be rapidly provisioned and released with minimal management effort or service provider interaction.

2           Basic Elelments:

Basic Elements of cloud computing consist of:

  • SaaS:Software as a Service
  • PaaS: Platfom as a Service
  • IaaS: Infrastructure as a Service
  • Utility Computing

Lets review these concepts separately.

2.1          SAAS:

According to wiki:

Software as a service is software that is deployed over the internet and/or is deployed to run behind a firewall in your local area network or personal computer. With SaaS, a provider licenses an application to customers as a service on demand, through a subscription or a “pay-as-you-go” model. Also called “software on demand”.

Benefits:

  • Save money by not having to purchase servers or other software to support use
  • Focus Budgets on competitive advantage rather than infrastructure
  • Monthly obligation rather than up front capital cost
  • Reduced need to predict scale of demand and infrastructure investment up front as available capacity matches demand
  • Multi-Tenant efficiency
  • Flexibility and scalability

 

2.2          PaaS:

PaaS offerings facilitate deployment of applications without the cost and complexity of buying and managing the underlying hardware and software and provisioning hosting capabilities, providing all of the facilities required to support the complete life cycle of building and delivering web applications and services entirely available from the Internet.

PaaS offerings may include facilities for application design, application development, testing, deployment and hosting as well as application services such as team collaboration, web service integration and marshalling, database integration, security, scalability, storage, persistence, state management, application versioning, application instrumentation and developer community facilitation. These services may be provisioned as an integrated solution over the web.

2.3          IaaS:

Cloud infrastructure services or “Infrastructure as a Service (IaaS)” delivers computer infrastructure, typically a platform virtualization environment as a service. Rather than purchasing servers, software, data center space or network equipment, clients instead buy those resources as a fully outsourced service. The service is typically billed on a utility computing basis and amount of resources consumed (and therefore the cost) will typically reflect the level of activity. It is an evolution of virtual private server offerings.

2.4          Utility computing:

Utility computing is the packaging of computing resources, such as computation and storage, as a metered service similar to a traditional public utility (such as electricity, water, natural gas, or telephone network). This system has the advantage of a low or no initial cost to acquire hardware; instead, computational resources are essentially rented. Customers with very large computations or a sudden peak in demand can also avoid the delays that would result from physically acquiring and assembling a large number of computers.

3           Essential Characteristics:

  • On-demand self-service. A consumer can unilaterally provision computing capabilities, such as server time and network storage, as needed automatically without requiring human interaction with each service’s provider.
  • Broad network access. Capabilities are available over the network and accessed through standard mechanisms that promote use by heterogeneous thin or thick client platforms (e.g., mobile phones, laptops, and PDAs).
  • Resource pooling. The provider’s computing resources are pooled to serve multiple consumers using a multi-tenant model, with different physical and virtual resources dynamically assigned and reassigned according to consumer demand. There is a sense of location independence in that the customer generally has no control or knowledge over the exact location of the provided resources but may be able to specify location at a higher level of abstraction (e.g., country, state, or datacenter). Examples of resources include storage, processing, memory, network bandwidth, and virtual machines.
  • Rapid elasticity. Capabilities can be rapidly and elastically provisioned, in some cases automatically, to quickly scale out and rapidly released to quickly scale in. To the consumer, the capabilities available for provisioning often appear to be unlimited and can be purchased in any quantity at any time.
  • Measured Service. Cloud systems automatically control and optimize resource use by leveraging a metering capability at some level of abstraction appropriate to the type of service (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported providing

 

4           Must differentiate with:

  1. Autonomic computing — “computer systems capable of self-management“.
  2. Client–server modelClient–server computing refers broadly to any distributed application that distinguishes between service providers (servers) and service requesters (clients).
  3. Grid computing — “a form of distributed computing and parallel computing, whereby a ‘super and virtual computer’ is composed of a cluster of networked, loosely coupled computers acting in concert to perform very large tasks”
  4. Mainframe — powerful computers used mainly by large organizations for critical applications, typically bulk data processing such as census, industry and consumer statistics, enterprise resource planning, and financial transaction processing.
  5. Utility computing — the “packaging of computing resources, such as computation and storage, as a metered service similar to a traditional public utility, such as electricity“.
  6. Peer-to-peer – a distributed architecture without the need for central coordination, with participants being at the same time both suppliers and consumers of resources (in contrast to the traditional client–server model). Deployment models

 

5           Deployment Models:

According to National Institute of Standards and Technology, there are following deployment models. 

  • Private cloud. The cloud infrastructure is operated solely for an organization. It may be managed by the organization or a third party and may exist on premise or off premise.
  • Community cloud. The cloud infrastructure is shared by several organizations and supports a specific community that has shared concerns (e.g., mission, security requirements, policy, and compliance considerations). It may be managed by the organizations or a third party and may exist on premise or off premise.
  • Public cloud. The cloud infrastructure is made available to the general public or a large industry group and is owned by an organization selling cloud services.
  • Hybrid cloud. The cloud infrastructure is a composition of two or more clouds (private, community, or public) that remain unique entities but are bound together by standardized or proprietary technology that enables data and application portability (e.g., cloud bursting for load-balancing between clouds).

 

6           Intercloud

The Intercloud is an interconnected global “cloud of clouds” and an extension of the Internet “network of networks” on which it is based.

The Intercloud scenario is based on the key concept that each single cloud does not have infinite physical resources. If a cloud saturates the computational and storage resources of its virtualization infrastructure, it could not be able to satisfy further requests for service allocations sent from its clients. The Intercloud scenario aims to address such situation, in fact, each cloud can use the computational and storage resources of the virtualization infrastructures of other clouds. Such form of pay-for-use introduces new business opportunities among cloud providers. Nevertheless, the Intercloud raises many challenges concerning cloud federation, security, interoperability, QoS, monitoring and billing.

7           Cloud Plateforms:

Following are some of best Cloud computing plateforms availiable in industry.
·         Amazon’s Elastic Compute Cloud, or EC2, is probably the most generalized and best-known of the cloud computing service offerings.
·         IBM Computing on Demand or Blue Cloud is a highly enterprise-focused cloud computing offering that, because it is related to and built with the same technology sold to enterprises, can cross over between public and private cloud applications.
·         Microsoft’s Azure cloud computing, based on Microsoft Vista and .NET technology, includes both cloud computing and cloud-hosted extension services. It also supports public and private cloud computing plans.
·         Sun Cloud, like IBM’s offering, is available both in public and private cloud forms. Since Oracle is acquiring Sun, this offering may change over time.
·         Salesforce.com’s Force.com cloud is easily integrated with Salesforce.com’s application tools.
·         Google’s AppEngine cloud offering is targeted particularly to web developers and web hosting applications. 

8           Cloud Applications:

  • Mint: A Cloud based personal finance tool, to manage your money. It was launched in September 2007. All money related accounts viz. Bank Accounts, Credit Card, Loan, Stock Brokerage & other Investment are provided in one place.
  • Panda Cloud Antivirus: The first free Antivirus from the cloud. It has received many decent reviews.
    • No need to worry about regular updates.
  •  
    • Occupies very little system resources.
    • It uses collective intelligence servers for fast detection
    • Simple interface. 
  • Amazon.com
    Amazon.com’s Customer Experience Analytics Team uses Amazon Relational Database Service to store and query customer simulation data.
  • Net Applications
    Net Applications gains a competitive edge over other Web analytics solutions by using Alexa Web Information Service to deliver in-depth Web traffic information.
  • Channel Intelligence
    Using Amazon Mechanical Turk, Channel Intelligence was able to leverage human intelligence around the globe and decrease task-specific costs by 85%.
  • Online suite

     Google’s online suite of office applications is probably the best known but by no means the only solution on offer.Examples of online suite’s on offer include Ajax13, ThinkFree and Microsoft’s Office Live.

Using Google Wave you can create a document and then invite others to comment, amend, offer opinion, or otherwise join in with the creation of the final draft.

Other examples include Spicebird, Mikogo, Stixy and Vyew to name but a few.

9           Criticism:

Larry Ellison, CEO of Oracle Corporation has stated that cloud computing has been defined as “everything that we already do” and that it will have no effect except to “change the wording on some of our ads”. Oracle Corporation has since launched a cloud computing center and worldwide tour.

Richard Stallman said that cloud computing was simply a trap aimed at forcing more people to buy into locked, proprietary systems that would cost them more and more over time. “It’s stupidity. It’s worse than stupidity: it’s a marketing hype campaign”, he told The Guardian. “Somebody is saying this is inevitable – and whenever you hear somebody saying that, it’s very likely to be a set of businesses campaigning to make it true.”

General References:

http://csrc.nist.gov/groups/SNS/cloud-computing/cloud-def-v15.doc

http://www.whatissoa.com/whatiscloud/default.php

http://aws.amazon.com/solutions/case-studies/

What is Cloud Computing?

http://en.wikipedia.org/wiki/Cloud_computing

http://searchcloudcomputing.techtarget.com/sDefinition/0,,sid201_gci1287881,00.html

http://cloudcomputing.sys-con.com/

Videos:

http://www.youtube.com/watch?v=6PNuQHUiV3Q

http://www.youtube.com/watch?v=XdBd14rjcs0&feature=related

http://www.youtube.com/watch?v=hplXnFUlPmg&feature=related

http://www.youtube.com/watch?v=SgujaIzkwrE&feature=channel

http://www.youtube.com/watch?v=oA5z0V5yJJE&feature=related

http://www.youtube.com/watch?v=OIbkMjrrdjQ&feature=channel