Th Technology Summit

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Th Technology Summit as PDF for free.

More details

  • Words: 6,246
  • Pages: 28
Application of Persistent Relational .NET Objects (using NHibernate), .NET based grid framework (using Alchemi.NET) and rich web client (using WPF, Silverlight) for content rich high performance business applications.

Satyaki Chatterjee (113830) Somnath Mukherjee (133045)

Content Abstract..........................................................................................................3 NHibernate......................................................................................................4 Object Relational Mapping...............................................................................4 The Problem.................................................................................................4 The Approach................................................................................................5 What is NHibernate?......................................................................................5 NHibernate key features.................................................................................5 Databases supported by NHibernate................................................................6 Limitations....................................................................................................6 Alternative Technologies.................................................................................6 Prerequisites/System Requirement...................................................................6 NHibernate Architecture.................................................................................6 Developers’ View...........................................................................................8 Alchemi.........................................................................................................12 Grid Computing...........................................................................................12 What is Alchemi?.........................................................................................14 How Alchemi Works......................................................................................14 Prerequisites/System Requirement.................................................................15 Architecture................................................................................................15 Configuration...............................................................................................16 Alternative Technologies...............................................................................18 Developers’ View.........................................................................................19 Silverlight......................................................................................................22 What is Silverlight........................................................................................22 Features.....................................................................................................22 Architecture of Silverlight..............................................................................22 Prerequisites/System Requirement.................................................................23 Developing a Simple Application....................................................................23 Deploying Silverlight Application on IIS...........................................................25 What Next..................................................................................................25 Alternative Technologies...............................................................................26 Persistent Layer - NHibernate........................................................................27 Business Components...................................................................................27 Grid Layer - Alchemi.....................................................................................27 Services......................................................................................................28 Presentation/UI Layer...................................................................................28 Conclusion.....................................................................................................28 Web References..............................................................................................28

Abstract NHibernate being a .NET port of the java based object relational framework Hibernate, handles persisting plain .NET objects to and from an underlying relation database. Alchemi allows to aggregate the computing power of networked computers into a virtual supercomputer (a Grid) and to develop applications to run on the grid. Silverlight is designed to provide a richer internet experience for enterprise and consumer applications. In this article we have tried to build a hypothetical design of content rich high performance business applications using these three technologies. Our goal is to simplify the data access layer and allow the developer to use plain old CLR objects for relational data handling. For the performance critical processes of the application we the Alchemi.NET grid is proposed, whose power can be leveraged by identifying the parallel executable sub-processes, in case of a multi user environment each user request can be treated as potential parallel processes by the system. To enrich the user interface with better content, graphics, animation, screen dynamics and user interaction we propose to use Silverlight.

NHibernate Object Relational Mapping Object-relational mapping is the process of transforming between object and relational modeling approaches and between the systems that support those approaches. Doing a good job at object-relational mapping requires a solid understanding of object modeling and relational modeling, how they are similar, and how they are different. Ideally we should have a single integrated model that described both approaches. This would make sure we understand and explicitly document both concepts and their relationships. This document will present what we believe to be the only correct integration of the two worlds that is suitable for implementation on a relational database. Difficulties occur when we have to deal with the real systems implementing object and relational models. These systems have implementations that are deficient or inconsistent with the theoretical approaches. Relational databases have been deficient for multiple decades in correctly implementing the core concepts of relational theory. On the other hand, object modeling is not standardized, so each programming environment implements its own variation. Because of these deficiencies object-relational mapping is more complicated than it needs to be. Fortunately, object modeling and relational modeling have such different concerns that they are actually extremely compatible. Relational theory is concerned with knowledge and object techniques are concerned with (primarily) behavior. Mapping between the two models requires deciding how the two worlds can refer to each other. We will first describe the two worlds in more detail and then show how they can be integrated.

The Problem Data management tasks in object-oriented (OO) programming are typically implemented by manipulating objects, which are almost always non-scalar values. Consider the example of an address book entry, which represents a single person along with zero or more phone numbers and zero or more addresses. This could be modeled in an object-oriented implementation by a "person object" with "slots" to hold the data that comprise the entry: the person's name, a list (or array) of phone numbers, and a list of addresses. The list of phone numbers would itself contain "phone number objects" and so on. The address book entry is treated as a single value by the programming language (it can be referenced by a single variable, for instance). Various methods can be associated with the object, such as a method to return the preferred phone number, the home address, and so on. Many popular database products, however, such as SQL DBMS products, can only store and manipulate scalar values such as integers and strings, organized within tables. The programmer must either convert the object values into groups of simpler values for storage in the database (convert them back upon retrieval), or only use simple scalar values within the program. Object-relational mapping is used to implement the first approach.

The crux of the problem is translating those objects to forms which can be stored in the database, and which can later be retrieved easily, while preserving the properties of the objects and their relationships; these objects are then said to be persistent.

The Approach Object-Relational mapping (aka O/RM, ORM, and O/R mapping) is a programming technique for converting data between incompatible type systems in databases and object-oriented programming languages. This creates, in effect, a "virtual object database" which can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ORM tools. An object-relational mapping implementation would need to systematically and predictably choose which tables to use and generate the necessary SQL. In overview, the impedance mismatch between the architectural approach of the object oriented application such as built in Java and where the data is stored in a relational database management system (RDBMS) such as Oracle or IBM's DB2 creates a rather complex set of challenges to deal with in order to accomplish tasks such as performance, linear scalability, manage the CRUD operations for even the most complex relationships without slowing down, eliminate coding SQL – ODBC - JDBC - Java to save time and create consistency in how this is handled, make maintenance and future application changes simple, requiring little or no effort, etc. The real values in using an ORM tool is to save time, simplify development (i.e. the ORM tool handles the complexity for the developer), increase performance or scalability, and minimize architectural challenges related to inability of the ORM tool or developer's experience.

What is NHibernate? NHibernate is an Object-relational mapping (ORM) solution for the Microsoft .NET platform: it provides an easy to use framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a significant amount of relational data persistence-related programming tasks. NHibernate is a port of Hibernate Core for Java to the .NET Framework. It handles persisting plain .NET objects to and from an underlying relational database. Given an XML description of your entities and relationships, NHibernate automatically generates SQL for loading and storing the objects. Optionally, you can describe your mapping metadata with attributes in your source code. NHibernate supports transparent persistence, your object classes don't have to follow a restrictive programming model. Persistent classes do not need to implement any interface or inherit from a special base class. This makes it possible to design the business logic using plain .NET (CLR) objects and object-oriented idiom.

NHibernate key features  Natural programming model - NHibernate supports natural OO idiom; inheritance, polymorphism, composition and the .NET collections framework, including generic collections.  Native .NET - NHibernate API uses .NET conventions and idioms  Support for fine-grained object models - a rich variety of mappings for collections and dependent objects

 No build-time bytecode enhancement - there's no extra code generation or bytecode processing steps in your build procedure  The query options - NHibernate addresses both sides of the problem; not only how to get objects into the database, but also how to get them out again  Custom SQL - specify the exact SQL that NHibernate should use to persist your objects. Stored procedures are supported on Microsoft SQL Server.  Support for "conversations" - NHibernate supports long-lived persistence contexts, detach/reattach of objects, and takes care of optimistic locking automatically  Free/open source - NHibernate is licensed under the LGPL (Lesser GNU Public License)

Databases supported by NHibernate        

Microsoft SQL Server 2000, 2005 Oracle Microsoft Access Firebird PostgreSQL DB2 UDB MySQL SQLite

Limitations Following are the main limitations of NHibernate – 1.

The NHibernate persistent classes are not SOAP serializable, thus can’t be exposed via web services. DTO (Data Transfer Objects) components must be used to wrap these beans before exposing via web service.

Alternative Technologies As an alternative of NHibernate, LINQ (see http://msdn2.microsoft.com/hiin/netframework/aa904594.aspx) can be used. The LINQ Project is a codename for a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

Prerequisites/System Requirement To use NHibernate Microsoft .NET Framework 1.1 or above must be installed on the system.

NHibernate Architecture

Figure 1 : NHibernate Architecture Here are some definitions of the objects in the diagrams:  ISessionFactory (NHibernate.ISessionFactory) A threadsafe (immutable) cache of compiled mappings for a single database. A factory for ISession and a client of IConnectionProvider. Might hold an optional (second-level) cache of data that is reusable between transactions, at a process- or cluster-level.  ISession (NHibernate.ISession) A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps an ADO.NET connection. Factory for ITransaction. Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier.  Persistent Objects and Collections Short-lived, single threaded objects containing persistent state and business function. These might be ordinary POCOs (Plain Old CLR Object), the only special thing about them is that they are currently associated with (exactly one) ISession. As soon as the Session is closed, they will be detached and free to use in any application layer (e.g. directly as data transfer objects to and from presentation).  Transient Objects and Collections Instances of persistent classes those are not currently associated with an ISession. They may have been instantiated by the application and not (yet) persisted or they may have been instantiated by a closed ISession.  ITransaction (NHibernate.ITransaction) (Optional) A single-threaded, short-lived object used by the application to specify atomic units of work. Abstracts application from underlying ADO.NET transaction. An ISession might span several ITransactions in some cases.  IConnectionProvider (NHibernate.Connection.IConnectionProvider) (Optional) A factory for ADO.NET connections and commands. Abstracts application from the concrete vendor-specific implementations of

IDbConnection and IDbCommand. Not exposed to application, but can be extended/implemented by the developer.  IDriver (NHibernate.Driver.IDriver) (Optional) An interface encapsulating differences between ADO.NET providers, such as parameter naming conventions and supported ADO.NET features.  ITransactionFactory (NHibernate.Transaction.ITransactionFactory) (Optional) A factory for ITransaction instances. Not exposed to the application, but can be extended/implemented by the developer.

Developers’ View Environment Configuration NHibernate environment configuration like database connection string can be done in three ways – 1. Specifying environment settings in the configuration file (Web.Config or App.Config) 2. Via the hibernate.cfg.xml of the main project. 3. Configured programmatically. Here we give the content of a sample hibernate.cfg.xml file <session-factory> <property name="connection.provider"> NHibernate.Connection.DriverConnectionProvider <property name="connection.driver_class"> NHibernate.Driver.SqlClientDriver <property name="connection.connection_string"> user=sa ; password=password1$;Initial Catalog=WEBAPPDBPOC;Data Source=CTSINCALSDAI\VRGUAT1;Connection Timeout=0; <property name="show_sql">true <property name="dialect">NHibernate.Dialect.MsSql2000Dialect <property name="use_outer_join">true <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N' <mapping assembly="POC.ClassLibrary" />

The Persistent POCO class Here is an example POCO class for the Item entity in the database – [System.SerializableAttribute()] [System.Xml.Serialization.XmlIncludeAttribute( typeof(POC.ClassLibrary.ItemAttribute))] [System.Xml.Serialization.SoapIncludeAttribute( typeof(POC.ClassLibrary.ItemAttribute))] public class Item { private int itemId;

private private ... private private

string itemCode; string itemName; POC.ClassLibrary.ItemCategoryMaster itemCategoryMaster; System.Collections.IList itemAttributes;

public virtual int ItemId { get { return this.itemId; } set { this.itemId = value; } } public virtual string ItemName { get { return this.itemName; } set { this.itemName = value; } } ...

public virtual POC.ClassLibrary.ItemCategoryMaster ItemCategoryMaster { get { return this.itemCategoryMaster; } set { this.itemCategoryMaster = value; } }

}

[System.Xml.Serialization.XmlIgnoreAttribute()] [System.Xml.Serialization.SoapIgnoreAttribute()] public virtual System.Collections.IList ItemAttributes { get { if (((this.itemAttributes != null) && (typeof(System.Array).IsAssignableFrom(this.itemAttributes.GetType()) == true))) { this.ItemAttributes = new System.Collections.ArrayList(this.itemAttributes); } return this.itemAttributes; } set { this.itemAttributes = value; } }

The O/R Mapping Here is an example O/R mapping done for the Item entity via the Item.hbm.xml – <property name="ItemName" type="System.String" column="Item_Name" not-null="true" length="255" />

... <many-to-one name="ItemCategoryMaster" class="POC.ClassLibrary.ItemCategoryMaster, POC.ClassLibrary" fetch="select">


Accessing data using the persistent objects Here is an example of accessing all items using the Item POCO – public List AllItems { get { List items = null; try {

ICriteria criteria = mSession.CreateCriteria ( typeof ( Item ) ); criteria.AddOrder ( NHEx.Order.Asc ( "ItemName" ) ); items = new List ( criteria.List ( ) ); if ( items == null || items.Count < 1 ) { return null; } else { return items; }

} catch ( Exception ex ) { throw ex; } }

}

One more example for a particular item id – public Item GetItemByItemId ( int itemId ) { List items = null; try {

ICriteria criteria = mSession.CreateCriteria ( typeof ( Item ) ); criteria.Add ( NHEx.Expression.Eq ( "ItemId", itemId ) );

criteria.AddOrder ( NHEx.Order.Asc ( "ItemName" ) ); items = new List ( criteria.List ( ) ); if ( items == null || items.Count < 1 ) { return null; } else { return items [ 0 ]; }

} catch ( Exception ex ) { throw ex; } }

Alchemi Grid Computing Grid computing is a critical shift in thinking about how to maximize the value of computing resources. Because it is an emerging technology, grid computing can mean different things to different people. But here is a simple, serviceable definition for the concept of grid computing: Grid computing allows you to unite pools of servers, storage systems, and networks into a single large system so you can deliver the power of multiple-systems resources to a single user point for a specific purpose. To a user, data file, or an application, the system appears to be a single enormous virtual computing system. Grid computing is the next logical step in distributed networking. Just as the Internet allows users to share ideas and files as the seeds of projects, grid computing lets us share the resources of disparate computer systems so people can actually start working on those projects. Grid computing takes the ability for computers (and their users) to communicate a step further: With grid computing, you can reach out and use computational or storage resources on machines other than your own. With grid computing, an organization can transform its distributed and difficult-tomanage systems into a large virtual computer that can be set loose on problems and processes too complex for a single computer to handle efficiently. The problems to be solved can involve data processing, network bandwidth, or data storage. The systems linked in a grid might be in the same room or distributed around the world. They might be running different operating systems on many hardware platforms. They might even be owned by different organizations. Regardless of the depth of a grid's resources, all the grid user experiences is the processing resources of a very large virtual computer. The major purpose of a grid is to virtualize resources to solve problems. The main resources grid computing is designed to give access to include, but are not limited to:  Computing/processing power  Data storage/networked file systems  Communications and bandwidth  Application software Since the concept of putting grids into real-world practice is still relatively new, another good way to describe a grid is to describe what it isn't. The following are not grids:  Clusters  Network-attached storage devices  Scientific instruments  Networks Each might be an important component of a grid, but by itself, doesn't constitute a grid. Being able to tie together several million computers -- clusters, workstations, desktop PCs, supercomputers -- with data storage, instruments, visualization devices is the dream grid computing strives to achieve and the reality of grid computing could be revolutionary to science and industry.

So, what does it take to make the vision of the grid computing concept a reality? It requires standard and seamless, open general-purpose protocols and interfaces, all of which are being defined now and are similar to those that enable access to information from the Web. Key Components of Grid Computing There are six major components to grid computing: 1. Security 2. User interface 3. Workload management 4. Scheduler 5. Data management 6. Resource management Computers on a grid are networked and running applications. They can also be handling sensitive or extremely valuable data, so the security component of grid computing is of paramount concern. This component includes elements such as encryption, authentication, and authorization. Accessing information on the grid is also quite important, and the user interface component handles this task for the user. It often comes in one of two ways:  An interface provided by an application that the user is running  An interface provided by the grid administrator, much like a Web portal that provides access to the applications and resources available on the grid in a single virtual space The portal-style interface is also important because it can be the help space for users to learn how to query the grid. Applications a user wants to run on a grid must be aware of the resources available. This is where a workload management service comes in handy. An application can communicate with the workload manager to discover the available resources and their status. A scheduler is needed to locate the computers on which to run an application and to assign the jobs required. This can be as simple as taking the next available resource, but this task often involves prioritizing job queues, managing the load, finding workarounds when encountering reserved resources, and monitoring progress. If an application is running on a system that doesn't hold the data the application needs, a secure, reliable data management facility takes care of moving that data to the right place across various machines, encountering various protocols. To handle such core tasks as launching jobs with specific resources, monitoring the status of those jobs, and retrieving results, a resource management facility is necessary. It's important to remember that grid computing doesn't operate in a vacuum. Just the opposite: It potentially involves every protocol and computer technology in operation today. With that in mind, we've provided links to other technologies and

standards you might need to understand to fully appreciate the scope of grid computing's power.

What is Alchemi? The idea of metacomputing is very promising as it enables the use of a network of many independent computers as if they were one large parallel machine, or virtual supercomputer for solving large-scale problems in science, engineering, and commerce. With the exponential growth of global computer ownership, local networks and Internet connectivity, this concept has been taken to a new level – grid computing. There is rapidly emerging interest in grid computing from commercial enterprises. A Microsoft Windows based grid computing infrastructure will play a critical role in the industry-wide adoption of grids due to the large-scale deployment of Windows within enterprises. This enables the harnessing of the unused computational power of desktop PCs and workstations to create a virtual supercomputing resource at a fraction of the cost of traditional supercomputers. However, there is a distinct lack of service oriented architecture-based grid computing software in this space. To overcome this limitation, Alchemi is implemented on the Microsoft .NET. While the notion of grid computing is simple enough, the practical realization of grids poses a number of challenges. Key issues that need to be dealt with are security, heterogeneity, reliability, application composition, scheduling, and resource management. The Microsoft .NET Framework provides a powerful toolset that can be leveraged for all of these, in particular support for remote execution (via .NET Remoting and web services), multithreading, security, asynchronous programming, disconnected data access, managed execution and cross-language development, making it an ideal platform for grid computing middleware. The Alchemi grid computing framework was conceived with the aim of making grid construction and development of grid software as easy as possible without sacrificing flexibility, scalability, reliability and extensibility. The key features supported by Alchemi are:  Internet-based clustering of desktop computers without a shared file system;  federation of clusters to create hierarchical, cooperative grids;  dedicated or non-dedicated (voluntary) execution by clusters and individual nodes;  object-oriented grid thread programming model (fine-grained abstraction); and  Web services interface supporting a grid job model (coarse-grained abstraction) for cross-platform interoperability e.g. for creating a global and cross-platform grid environment via a custom resource broker component.

How Alchemi Works There are four types of distributed components (nodes) involved in the construction of Alchemi grids and execution of grid applications: Manager, Executor, User & CrossPlatform Manager.

Figure 2: How Alchemi Works A grid is created by installing Executors on each machine that is to be part of the grid and linking them to a central Manager component. The Windows installer setup that comes with the Alchemi distribution and minimal configuration makes it very easy to set up a grid. An Executor can be configured to be dedicated (meaning the Manager initiates thread execution directly) or non-dedicated (meaning that thread execution is initiated by the Executor.) Non-dedicated Executors can work through firewalls and NAT servers since there is only one-way communication between the Executor and Manager. Dedicated Executors are more suited to an intranet environment and nondedicated Executors are more suited to the Internet environment. Users can develop, execute and monitor grid applications using the .NET API and tools which are part of the Alchemi SDK. Alchemi offers a powerful grid thread programming model which makes it very easy to develop grid applications and a grid job model for gridenabling legacy or non-.NET applications. An optional component (not shown) is the Cross Platform Manager web service which offers interoperability with custom non-. NET grid middleware.

Prerequisites/System Requirement To use Alchemi.NET Microsoft .NET Framework 1.1 or above must be installed on the system(s). The Manager should be installed on a stable and reasonably capable machine. The Manager requires SQL Server 2000 (or above) or MSDE 2000. The Alchemi Executor can be installed in two modes - as a normal Windows desktop application As a windows service (supported only on Windows NT/2000/XP/2003).

Architecture Alchemi follows the master-worker parallel programming paradigm in which a central component dispatches independent units of parallel execution to workers and manages them. This smallest unit of parallel execution is a grid thread, which is conceptually and programmatically similar to a thread object (in the object-oriented sense) that wraps a "normal" multitasking operating system thread. A grid application is defined simply as an application that is to be executed on a grid and that consists of a number of grid threads. Grid applications and grid threads are exposed to the grid application developer via the object oriented Alchemi .NET API.

Figure 3: Alchemi Architecture

Configuration  Cluster (Desktop Grid) The basic deployment scenario – a cluster - consists of a single Manager and multiple Executors that are configured to connect to the Manager. One or more Owners can execute their applications on the cluster by connecting to the Manager. Such an environment is appropriate for deployment on Local Area Networks as well as the Internet. The operation of the Manager, Executor and Owner components in a cluster is as described above.

Figure 4: Cluster

Figure 5: Legends

 Multi-Cluster A multi-cluster environment is created by connecting Managers in a hierarchical fashion. As in a single-cluster environment, any number of Executors and Owners can connect to a Manager at any level in the hierarchy. An Executor and Owner in a multi-cluster environment connect to a Manager in the same fashion as in a cluster and correspondingly their operation is no different from that in a cluster. The key to accomplishing multi-clustering in Alchemi's architecture is the fact that a Manager behaves like an Executor towards another Manager since the Manager implements the interface of the Executor. A Manager at each level except for the topmost level in the hierarchy is configured to connect to a higher level Manager as an “intermediate” Manager and is treated by the higher level-Manager as an Executor. Such an environment is more appropriate for deployment on the Internet. The operation of an intermediate Manager in a multi-cluster environment therefore, must be discussed with respect to the behavior of an Executor and is as follows. Once Owners have submitted grid applications to their respective Managers, each Manager has “local” grid threads waiting to be executed. As discussed, threads are assigned the highest priority by default (unless the priority is explicitly specified during creation) and threads are scheduled and executed as normal by the Manager’s local Executors. Note that an ‘Executor’ in this context could actually be an intermediate Manager, since it is treated as an Executor by the higher-level Manager. In this case after receiving a thread from the higher-level Manager, it is scheduled locally by the intermediate Manager with a priority reduced by one unit and is executed as normal by the Manager’s local ‘Executors’ (again, any of which could be intermediate Managers). In addition, at some point the situation may arise when a Manager wishes to allocate a thread to one of its local Executors (one or more of which could an intermediate Manager), but there are no local threads waiting to be executed. In this case, if the Manager is an intermediate Manager, it requests a thread from its higher-level Manager, reduced the priority by one unit and schedules it locally. In both of these cases, the effect of the reduction in priority of a thread as it moves down the hierarchy of Managers is that the “closer” a thread is submitted to an Executor, the higher is the priority that it executes with. This allows a portion of an Alchemi grid that is within one administrative domain (i.e. a cluster or multi-cluster under a specific “administrative domain Manager”) to be shared with other organizations to create a collaborative grid environment without impacting on its utility to local users. As with an Executor, an intermediate Manager must be configured for either dedicated or non-dedicated execution. Not only does its operation in this respect mirror that of an Executor, the same benefits of flexible resource management and deployment under network constraints apply.

Figure 6: Multi-Cluster  Cross-Platform Grid The Cross-Platform Manager can be used to construct a grid conforming to the classical global grid model. A grid middleware component such as a broker can use the Cross-Platform Manager web service to execute crossplatform applications (jobs within tasks) on an Alchemi node (cluster or multi-cluster) as well as resources grid-enabled using other technologies such as Globus.

Figure 7: Cross-Platform Grid

Alternative Technologies As an alternative Bayanihan Computing .NET (see http://bayanihancomputing.net/) can be used. Bayanihan Computing .NET is a generic Grid computing framework based on Microsoft .NET that uses Web services to harness computing resources through 'volunteer' computing similar to projects such as SETI@Home, and to make the computing resources easily accessible through easy-to-use and interoperable computational Web services. Globus (see http://www.globus.org/) is also an alternative grid solution based on Java. The Globus Toolkit is an open source software toolkit used for building Grid systems and applications. It is being developed by the Globus Alliance and many others all over the world. A growing number of projects and companies are using the Globus Toolkit to unlock the potential of grids for their cause.

Developers’ View Implementing the GThread class To write a grid thread class, we derive a new class from the Alchemi.Core. Owner,GThread class and override the void Start() method. We must also add the Serializable attribute to it: using using using using using using

System; System.Threading; System.Reflection; System.Text; Alchemi.Core; Alchemi.Core.Owner;

namespace POC.Alchemi.PiCalculator { [Serializable] public class PiCalcGridThread : GThread { private int startDigitNum; private int numDigits; private string result; public int StartDigitNum { get { return startDigitNum ; } } public int NumDigits { get { return numDigits; } } public string Result { get { return result; } } public PiCalcGridThread(int startDigitNum, int numDigits) { this.startDigitNum = startDigitNum; this.numDigits = numDigits; } public override void Start() { StringBuilder temp = new StringBuilder(); PlouffeBellard pb = new PlouffeBellard(); for (int i = 0; i <= Math.Ceiling((double)numDigits / 9); i++) { temp.Append ( pb.CalculatePiDigits ( startDigitNum + ( i * 9 ) ) ); } } }

result = temp.ToString ( ).Substring ( 0, numDigits );

}

The Grid Application – Now that we have written our parallel code, we can go about writing code that runs it on the grid. For this, we use the GApplication class. GApplication is a container for

executing grid threads and is used to interact with the grid. In the Main method of the application, 100 PrimeNumberChecker grid threads are created and added to the App grid application's Threads property (a GThread collection). using using using using using using

System; System.Reflection; System.Text; Alchemi.Core; Alchemi.Core.Owner; Alchemi.Core.Utility;

namespace POC.Alchemi.PiCalculator.Main { class PiCalculatorMain { static int numThreads = 10; static int digitsPerThread = 10; static int numberOfDigits = numThreads * digitsPerThread; static GApplication app; static int th = 0; [STAThread] static void Main ( ) { try { // get the number of digits from the user bool numberOfDigitsEntered = false; while ( ! numberOfDigitsEntered ) { try { Console.Write ( "Digits to calculate: " ); numberOfDigits = Int32.Parse ( Console.ReadLine ( ) ); if ( numberOfDigits > 0 ) { numberOfDigitsEntered = true; } } catch ( Exception ) { Console.WriteLine ( "Invalid numeric value." ); numberOfDigitsEntered = false; } } // get settings from user GConnection gc = new GConnection ( "localhost", "9000", "user", "user" ); // create a new grid application app = new GApplication ( gc ); app.ApplicationName = "PI Calculator - Alchemi POC"; // add the module containing PiCalcGridThread to the application manifest app.Manifest.Add ( new ModuleDependency ( typeof ( POC.Alchemi.PiCalculator.PiCalcGridThread ).Module ) ); NumThreads = ( Int32 ) Math.Floor ( ( double ) numberOfDigits / digitsPerThread ); if ( digitsPerThread * numThreads < numberOfDigits ) {

}

NumThreads++;

// create and add the required number of grid threads for ( int i = 0 ; i < numThreads ; i++ ) { int startDigitNum = 1 + ( i * digitsPerThread ); /// the number of digits for each thread /// Each thread will get DigitsPerThread digits except the last one /// which might get less int digitsForThisThread = Math.Min ( digitsPerThread, numberOfDigits - i * digitsPerThread ); PiCalcGridThread thread = new POC.Alchemi.PiCalculator.PiCalcGridThread ( startDigitNum, digitsForThisThread); }

app.Threads.Add ( thread );

// subcribe to events app.ThreadFinish += new GThreadFinish ( ThreadFinished ); app.ApplicationFinish += new GApplicationFinish ( ApplicationFinished ); // start the grid application app.Start ( );

} catch ( Exception e ) { Console.WriteLine ( "ERROR: {0}", e.StackTrace ); } Console.ReadLine ( ); } static void ThreadFinished ( GThread thread ) { th++; // Console.WriteLine("grid thread # {0} finished executing", thread.Id); } static void ApplicationFinished ( ) { StringBuilder result = new StringBuilder ( ); for ( int i = 0 ; i < app.Threads.Count ; i++ ) { POC.Alchemi.PiCalculator.PiCalcGridThread pcgt = ( POC.Alchemi.PiCalculator.PiCalcGridThread ) app.Threads [ i ]; result.Append ( pcgt.Result ); } Console.WriteLine ( "The value of Pi to {0} digits is:{1}", numberOfDigits, result ); } }

}

Silverlight What is Silverlight Silverlight (formerly known as WPF/E or Windows Presentation Foundation / Everywhere) is a cross-platform browser plug-in being developed by Microsoft that is designed to provide a richer internet experience for enterprise and consumer applications. Silverlight 1.0 has been called a "Flash killer" in that it will provide enhanced animation, vector graphics, and video playback capabilities. Although these features are interesting for improving the multimedia experience on the web, the real potential for Silverlight lies in the feature set to be released with version 1.1

Features The Silverlight version 1.0 feature set includes the following:  Declarative content format based on Extensible Application Markup Language (XAML).  JavaScript-based programming model.  Deployment options for content: in-line with the HTML page, as loose files, or in a compressed zip package.  Media support, including support for Windows Media Video (WMV), Windows Media Audio (WMA), and MPEG Audio Layer-3 (MP3), delivered with Windows Media Services or progressive download. Also includes support for client-side playlists (ASX files).  Text.  Image (PNG and JPG) support.  Anti-aliased vector graphics engine.  Animation.  Mouse and keyboard input.  HTTP downloader.  Full-screen rendering support.

Architecture of Silverlight The Silverlight runtime enables users to integrate media, vector graphics, text, and images into an interactive application. This section discusses some of the key components provided in Silverlight 1.0.

Figure 8: Architecture of Silverlight

Prerequisites/System Requirement Following are the components we need to develop a Silverlight app  .Net Framework -3.0 and above.  IDE Version - Visual Studio 2005 Team Edition with the WPF extension Or VS 2008  Silver Light 1.0 Runtime  Visual Studio 2005 service pack 1 for Silver Light 1.0 project template  Microsoft Expression Blend( Optional for design purpose )

Developing a Simple Application Silver Light Application=XAML+JAVA Script +Html

Structure of a Silver Light Application

Figure 9: Structure of a Silver Light Application Function of SilverLight.js

Figure 10: Function of SilverLight.js

Deploying Silverlight Application on IIS To deploy the application in a web server we need to change the mime type of the server. .Net framework (V3.0) or silver light component is not required on the server. Just we have to enter following entries in the mime type section Extension: .XAML Mime Type: application/xaml+xml

Figure 11: Deploying Silverlight Application on IIS

What Next Silver light 1.0 is still in the nascent state. Main power of the silver light will be revealed on the version 1.1. Silver light 1.1 will consists following features  C# coding architecture.  Much more flexibility on the graphics.  Much more basic controls such as text box radio button etc.  Communication with web service.

Alternative Technologies Flex (see http://flex.org/ and http://www.adobe.com/devnet/flex/) is a good alternative to Silverlight. Flex is a framework that helps you build dynamic, interactive rich Internet applications. Flex applications are delivered on the web via the Flash Player or to the desktop via Adobe Apollo.

Usage of NHibernate and Alchemi to build high performance applications B U S I N E S S

O R Database

M NHibernate A P P O P C I O N G

C O M P O N E N T S

G R I D

G R E AlchemiI X D E C A U P T P O R

WEB SERVICE SERVICES

DTO

Figure 12: Application Architecture

Persistent Layer - NHibernate We propose to implement NHibernate at this layer, to leverage power of object relational persistence along with the ease and simplification of the coding/construction effort. This layer consists of the bean (oops sorry Java guys for borrowing your term) classes which encapsulate the DB entities as a wrapper to be used directly in the application layer. NHibernate OR mapping xml does the underlying DB Entity – Persistent Object mapping.

Business Components The Business component layer consists of the business entities which either inherit the persistent objects or use those persistent object (via messaging or containment) to implement the business objectives of the application.

Grid Layer - Alchemi This layer uses the Alchemi grid distributed either as a uni-cluster or a multi cluster. The Grid Executor comprises of the GThread sub-classes. The GThread subclasses are implemented for the performance critical operations of the application; like search. The Grid Application is the main application component of the Alchemi layer which controls and manages the GThread components for which thread to be activated on which context and with the proper parameter set.

U S E R I N T E R F A C E

Services The Services layer consists of the Web Services which internally uses the DTO (Data Transfer Objects) components, and exposes the application services in terms of the DTO entities. Using the DTO classes is necessary because NHibernate base beans are not SOAP serializable, thus can’t be exposed via web services directly.

Presentation/UI Layer The UI layer (the web pages); use the web services for the core functionalities. Silverlight can be used in this layer.

Conclusion To keep stress on the main two aspects, viz. Content Rich and High Performance, of the proposed solution, we have tried to glue three frameworks each being master in their own domain. It may seem that we compromising performance by using NHibernate as an object relational wrapper over the relational database. But the simplicity of application development and usage of plain CLR objects in the grid application makes it much maintainable. Moreover NHibernate do not restrict usage of stored procedures. Some of the application logic, which can not be parallelized, can be implemented by stored procedures. The plus point of using Alchemi.NET grid for performance critical computations is its scalability. Grid executors can be added at any time of the application lifecycle. Silverlight, which is still in its budding phase, is going to be a leader in the rich internet applications.

Web References 1. 2. 3.

http://www.nhibernate.org/ http://www.alchemi.net/ http://www.silverlight.net/

Related Documents

Th Technology Summit
November 2019 5
Th Technology Summit
November 2019 3
Th
November 2019 53
Th
October 2019 54
Th
June 2020 39