On this page...
Archive
| May, 2010 (2) |
| April, 2010 (2) |
| March, 2010 (3) |
| February, 2010 (5) |
| November, 2009 (4) |
| October, 2009 (2) |
| October, 2008 (2) |
| July, 2008 (3) |
| June, 2008 (4) |
| April, 2008 (1) |
| January, 2007 (3) |
| December, 2006 (2) |
| October, 2006 (1) |
| September, 2006 (1) |
| August, 2006 (4) |
| July, 2006 (2) |
Categories
Archives
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 25 | 26 | 27 | 28 | 29 | 30 | 31 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | 8 | 9 | 10 | 11 | 12 | 13 | 14 | | 15 | 16 | 17 | 18 | 19 | 20 | 21 | | 22 | 23 | 24 | 25 | 26 | 27 | 28 | | 29 | 30 | 31 | 1 | 2 | 3 | 4 |
Links
|
By Pavel, a .NET Developer on Murano Software’s team One of the new, pleasant features of Silverlight 4 RC is comprehensive printing support, enabling hardcopy reports and documents, as well as a virtual print view, independent of screen content. We used this feature while updating RCA POC project phase 2, and we want to give a little overview of how to use this feature. Printing API The PrintDocument class provides printing capabilities from a Silverlight application. A developer can handle three events of this class: StartPrint, EndPrint and PrintPage. The StartPrint event is used for special handling or setting up before printing begins. The EndPrint event is used for clean up or other operations after printing is complete. Use the PrintPage event to generate page content for printing by setting the PrintPageEventArgs argument. The PrintPageEventArgs class contains three main properties: PageVisual, HasMorePages and PrintableArea. The PageVisual property sets the element for printing. It can be the layout root of Silverlight content or the name of UIElement. The PrintableArea gets the size of the printable area. You can use the HasMorePages property for printing multiple pages. If HasMorePages = true, then the PrintPage event is called again to print the next page. Sample:
private void PrintAll_Click(object sender, RoutedEventArgs e)
{
PrintDocument docToPrint = new PrintDocument();
// prepare to print
docToPrint.BeginPrint += (s, args) =>
{
// do something
};
// set UIElement
docToPrint.PrintPage += (s, args) =>
{
args.PageVisual = this.StackOfStuff;
args.HasMorePages = true;
};
// ending prepare to print
docToPrint.EndPrint += (s, args) =>
{
// do something
};
// start print
docToPrint.Print("Entire Screen Sample";);
}
Print Preview
We reviewed the main features of Printing API. Now let's look at how to implement a preview of the printed content. It’s easy. You have to create a User control where your printable data will be showed in the way you need. Then you set this control to the PageVisual property of the PrintPageEventArgs and print it.
Examples
The following code example shows a PrintPage event handler in RCA POC project, where stPage is a grid in the PrintPreviewBox control and the document is an instance of the PrintDocument class:
document.PrintPage += (sender1, args) =>
{
((Grid)stPage.Children[pagesPrinted]).Width = args.PrintableArea.Width;
((Grid)stPage.Children[pagesPrinted]).Height = args.PrintableArea.Height;
args.PageVisual = stPage.Children[pagesPrinted];
pagesPrinted++;
args.HasMorePages = stPage.Children.Count > pagesPrinted;
};
Then we invoke the method Print() of document object. This will show a print dialog, where we can select a printer. After that, Silverlight will generate the document and send it to the printer. You can see a preview page from RCA POC project on figure below.
Conclusion
As you can see, Silverlight 4 RC allows a developer to print documents with any content, whether photos, charts or text.
By Denis, a .NET Developer on Murano Software’s team One of the updates in the RCA phase 2 was a porting our database from Azure storage to Azure SQL. Minimal changes we needed to make were on the server (Azure web/web role) and Azure SQL. We also changed some scripts on the client to increase performance. Let’s look at the changes in the main two steps: Changes in the Azure SQL The main differences between Azure storage and Azure SQL are: - Each table in Azure storage has two key fields: RowKey and PartitionKey.
- A database in Azure storage is not relational, so no joins, group by and order by.
- Windows Azure storage can return either 1,000 rows or 4 Kbytes.
- Two key fields must be properly designed for good performance.
We also want to note that Azure SQL has some limitations as compared to traditional RDBMS. We couldn’t make a connection to Azure SQL from Visual studio before version 2010 RC, and we had to create copy of the Azure SQL database on the local SQL Server, make a model and change the connection string to the database in Azure SQL. But this problem was resolved in VS 2010 RC, and we can work with Azure SQL directly. Thus, we removed PartitionKey and RowKey, as well as TimeStamp, from the structure of each table because these keys can’t be used as primary keys in relational database. Then we formed primary keys and relations between tables. We didn’t find any tool to migrate the database from Azure storage to Azure SQL. So we implemented sql-script to create our database structure by hand. We want to note that you can work with Azure SQL, as well as the traditional SQL Server, using SQL Server 2008 R2 Management Studio CTP. One of the most pleasant features of this tool is the script generator that can generate script from an existing database. A generated script is adapted to Azure SQL and can create a database in Azure SQL. So you can create a database in the local SQL Server and use it in your Rich Internet Application before releasing and generating the database in Azure SQL only for the production version. Changes on the server (Web role / Azure Web) We used the data access layer described in this blog (Porting Silverlight RIA to Windows Azure) to work with Azure storage. The next step was to decide what kind of technology we would use to work with Azure SQL. We chose the LINQ to SQL technology. So we changed the previous model to a model generated by the DBML Code Generator. Our new model has to be inherited from the IUpdatable interface, so we implemented a partial class of our model that inherits from the IUpdatable interface. A generic implementation of the IUpdatable interface for LINQ to SQL is provided under MS-PL license. You can find it here and use it in the partial class of your model. These are all minimal changes you need to make to port your Azure storage to Azure SQL. Good luck.
By Stanislav, a Senior .NET Developer on Murano Software’s team The latest version of Silverlight delivers hundreds of features, such as a full set of form controls, enhanced data-binding support, printing API, UDP, webcam and microphone support, full trust in out-of-browser, and so on. But it doesn't have an out-of-box solution to stream video or audio captured from a microphone and Web camera via a network. Current API allows you to capture video/audio data from media devices, and it has a way to play back media information using MediaStreamSource and MediaElement control. Also, API has the UdpAnySourceMulticastClient class, which is a client receiver for multicast traffic from any source, also known as Any Source Multicast (ASM) or Internet Standard Multicast (ISM). Silverlight 4 gets support for microphones and webcams. It allows us to have access to the raw streams. The added support opens a lot of opportunities for new types of applications. During our work on http://code.msdn.microsoft.com/rca (source code is available under the MS-PL license), we created an application that allows users to communicate over the local network and to establish video/audio conferencing. The classes that expose this functionality live in the System.Windows.Media namespace. There are two classes that give us access to audio and video (AudioSink, VideoSink). To obtain video information from a video input device in Silverlight, you have to derive a custom video sink from VideoSink, which exposes several virtual callbacks: - OnCaptureStarted
- OnCaptureStopped
- OnFormatChange
- OnSamples
When you derive from VideoSink, you must provide overrides for the callbacks in order to compile. protected override void OnSamples(long sampleTime, long frameDuration, byte[] sampleData)
{
// Some code here...
}
The idea was to split data related to the particular frame into a set of packets, renumber them, add additional information and send them over the network.
On the client side, the application receives the mentioned packets, orders them, recovers the frame structure and passes frames to MediaElement, using MediaStreamSource.
The sources can be downloaded here. All logic related to the media chat is located in the PSO.Client.UDPMediaChat project (see Figure 1). It contains the following classes:
| Class name |
Description |
| MediaFrame |
Contains all related data to the media sample |
UdpAudioSink,
UdpVideoSink |
These classes are responsible for the capturing raw media data and passing it to the appropriate media channel. |
VideoPacketChannel,
AudioPacketChannel |
These classes are responsible for the preparing data for the transmission. They split media samples into a set of packets and pass them to the transmitter. |
| NetPacketTransmitter |
It contains the logic of the transmission and receives NetPackets over the network. |
NetAudioPacketSerializer,
NetVideoPacketSerializer |
These classes are responsible for the logic of packet serialization and de-serialization. |
NetVideoPacket,
NetAudioPacket |
Stores all necessary media data that is prepared to send over the network. |
| StreamingServer |
Contains logic that allows users to organize raw media data transmission over the network. |
| MediaFrameSource |
Contains media buffering logic. |
| RawMediaStreamSource |
Contains the logic of the prepared media samples for the playback by MediaElement |
Table 1. The description of the most important classes.
Figure 1. Solution explorer
Sequence diagrams show how the application processes media samples before sending them over a network.
We streamed raw data without any compression. Unfortunately, Silverlight doesn't supply codecs yet, but we suppose that it's possible to compress media streams using COM Object Access in Trusted Applications.
Figure 2 shows that we have two media data sources (VideoSink and AudioSink). They pass media data to the corresponding media packet channel, which is responsible for the media frames’ (samples’) processing and further transmission. We want to note that these sinks work separately in different threads. Also, the media channel contains frames splitting logic into a pile of packets. Each packet is sent over the network separately.

Figure 2. Sequence diagram shows simplified algorithm of raw media streaming.
When you use a multicast client, the first thing you have to do is to join the group, using the known multicast IP address (ex: 224.0.0.1 - The All Hosts multicast group that contains all systems on the same network segment) and the port (ex: 9999). The address block 224.0.0.0/24 (224.0.0.0 to 224.0.0.255) is designated for multicasting on the local subnetwork only. When the connection has been made, you can start send and/or receive from the group.
There are several security restrictions on connecting to multicast groups in Silverlight.
The security policy checks included in the Silverlight runtime are designed to prevent networking threats like DoS attacks, DNS rebinding, reverse tunnel attack, etc. Currently, it's not possible to connect to remote ports less then 1024. Before a multicast client is allowed to join a group, the Silverlight runtime implements a protocol check to verify that the client has been granted permission to join the group and receive datagrams.
Sink produces raw media data by the callback:
protected override void OnSamples(long sampleTime, long frameDuration, byte[] sampleData)
{
// Some code here...
}
These data are packed in a media frame and passed to the corresponding media channel. The channel splits the media frame into a set of packets because UdpAnySourceMulticastClient restricts the amount of data that can be sent at once. So the application cuts huge media frames that contain raw media data into small pieces and sends them over the network.

Figure 3. Sequence diagram shows simplified playback algorithm of the raw media stream.
On the client side, UdpAnySourceMulticastClient receives raw bytes. It passes them to NetPacketTransmitter. The transmitter verifies the destination address and “unpacks” the packet.
Then the transmitter notifies the media channels that the packet with media data has been received.
Each channel verifies the ability to process the incoming packet. The logic of the channels could vary drastically, depending on the nature of the received data. For instance, VideoChannel uses a special mechanism for the video frames recovery from a set of packets. When the media channel decides that a subsequent frame is received completely, it passes it to the MediaFrameSource.
This class manages media frame queues for both audio and video frames. Each received frame is added to the particular queue. The frames from the queues are pulled by the MediaStreamSource.
If the queue is empty, the thread that serves MediaStreamSource is suspended until the queue receives at least one frame.
Figure 5. Audio chat window
A user can perform a call to other user by clicking on the phone icon at the left-side of the main window. The other participant has to confirm the call. If the call is confirmed, the special media control will be displayed (see Figure 5). By default PSO establishes an audio conference. If you want to perform a video call you have to press the film icon. In this case your application instance will start a video transmission and the other participant will be able to see you. The video chat window is displayed on figure 6.
Figure 6. Video chat window
We successfully realized a proof of concept that shows the possibility of video conference software development on the Silverlight 4 technology. Also, we built a universal extensible framework that allows users to transmit data in the local network.
By Denis, a .NET Developer on Murano Software’s team We are glad to present the release of the new extended version of Rich Cloud Application (RCA) that was announced in the last Rich Cloud Application blog post. The main enhancements of this version are using Silverlight 4 RC features, SQL Azure and Microsoft SyncFx: - Using Silverlight’s comprehensive printing support. Any registered user can make a hard copy, as well as a virtual printing view, of any report in the system.
- Using a microphone and Web camera in the world of today is the standard de facto of user collaboration on the Internet. We extended the private chat with the possibility of using a microphone and a Webcam for more effective cooperation.
- Another cool feature of Silverlight 4 RC is multicast networking, enabling enterprises to lower the cost of streaming broadcast events. We implemented video/audio stream broadcasting for video chat in the system by using UDP multicast.
- Implementation of a new, complex rating system requires us to move the database from Azure storage to Azure SQL. All changes that are needed to move the application from Azure storage to Azure SQL will be described in the next blog post.
- We implemented the possibility of comfortably working with our system in off-line mode. The user can run the application in out-of-browser mode and work with cached data. Any changes in cache will be synchronized with storage in Azure SQL by Microsoft SyncFX while online.
Click below to take a look at screenshots of the application in action or try it online at http://pso.cloudapp.net! The full source of code, except synchronization, is available for download at the MSDN Code Gallery under the MS-PL license. You can find some interesting solutions and work-arounds for creating peer-to-peer video chat and printing support. So stay tuned and subscribe to our blog to get fresh news about Rich Cloud Application!
By Alex, a Senior .NET Developer on Murano Software’s team As Microsoft Azure spreads, the cloud computing and scaling technologies are getting more and more familiar among the software developers. This is very essential, since nowadays startups scale fast or fail fast. One of the advanced scaling techniques is sharding, which is horizontal data partitioning, when large and scalability-sensitive data (e.g., a person's profiles and his or her messages) are split into several shards by certain criteria (regional, alphabetical and so on). You can add a new shard at any time to scale out with less cost due to its smaller size and hardware requirements. All giants like Flickr and Google are using shards in their architecture. There is a good amount of network resources concerning sharding — e.g., at highscalability.com or here. You can look at the discussion in this blog as a great example of sharding pros and cons from a practical angle. Sharding has many difficult aspects and requires superior expertise in architecture and a large investment in the design of your system. What concerns SQL Azure is that there are size limitations for the databases (originally they were up to 10Gb for a single database). Although Microsoft announced 50Gb databases, the problem is still present for rapidly growing startups, and Microsoft considers sharding one of the recommended solutions. Previously, sharding was a high-end technology, but now it is knocking at the door of an average software development team. Our company is going to develop an architectural guideline and software extensibility kit, providing implementations for common sharding tasks, such as shard location service, and using all the benefits of Microsoft Azure as a platform.
Our goal During the Microsoft SharePoint 2010 Social Fest, Murano’s programmers had to create seven applications for the new SharePoint Server 2010. This article will show how Amazon Web Services helped us to get results in just seven days. Why did we choose Amazon? We had few days before the Microsoft SharePoint 2010 Social Fest to test the new SharePoint server. Microsoft’s SharePoint Server 2010 is in beta status and has strict hardware requirements. You must have 4GB of RAM to start working with it. Also, the best way to use SharePoint Server 2010 is to install it on a Windows Server 2008 or Windows Server 2008 R2 operating system. So we had to upgrade some of the developers’ PC hardware and OS or find another solution. There also was another problem – how to prepare the environment for the new developers on SharePoint Social Fest’s team very quickly. We decided to check Amazon services. Amazon Elastic Compute Cloud (Amazon EC2) is a Web-based service that provides compute capacity in the cloud. Amazon EC2 presents a virtual computing environment, allowing you to use Web service interfaces to launch instances with selected operating systems. Fortunately, MS Windows Server 2008 is available to use on Amazon. We chose “Large Instance” with 8GB RAM and 4 EC2 Compute Units to handle our tasks. How to start using Amazon Web Services Getting to Amazon’s cloud is simple. You have to go to http://aws.amazon.com/ec2 and register a new account if you don’t have one. After registering for service and filling out your card data, you can create a new instance by wizard in EC2 AWS console:  After passing several steps, you will get new instances in the console:  Now instances on Amazon EC2 use ELASTIC BLOCK STORE (EBS) to store data volumes. This is good news because your data will stay alive after instance shutdown. Our results Virtual servers on Amazon have a good performance level. We used Visual Studio 2010 on it with hosted SharePoint 2010 sites, and the machines worked very promptly. As we selected Amazon EC2 as our platform for the SharePoint 2010 Social Fest, we had to find out how to multiply the development environment in a short time. The “Snapshot” function could help. It will take a snapshot from the selected data volume. Then you can create a new volume from the snapshot and attach it to the instance. But I found that instance’s Amazon Machine Image (AMI) creation is more applicable for our task. You can install any software you need, make your changes to the system configuration and then create an image of your instance. Then you can use this image for creating new instances. Using AMIs instead of snapshots gives you an advantage in time because you will already get a configured instance right after the launch.  Thus we prepared AMI with Visual Studio 2010 beta and SharePoint Server 2010 beta installed on it, and we used it any time our developer needed a new environment. Benefits of using Amazon Using Amazon Elastic Compute Cloud gives all our programmers the possibility of working with the demanding SharePoint Server 2010 without OS reinstallation and hardware upgrade. Also, we find that Amazon EC2 is very convenient if you need to increase the quantity of servers very quickly. You could use Command Line Tools to automate some tasks with EC2 instances. We used it to enable programmers to shut down and start their instances. 
By Denis, a .NET Developer on Murano Software’s team The growing popularity of cloud computing can easily be explained by the high ROI that users get. In contrast to using SOA, with cloud computing, users receive a great number of benefits with minimal capital expenditures. According to many studies, the main advantages of cloud technologies are the reduction in the costs of building and extending on-premises resources, the reduction in the effort and costs of IT management, and the increase in flexibility and scalability. There is no question that cloud computing is going to play a big part in the future hosting, scaling and managing of Web applications. Microsoft introduced a new operation system, Windows Azure, as “a cloud service operation system that serves as the development, service hosting and service management environment for Windows Azure platform”. The goal of Windows Azure is to provide developers “with on-demand compute and storage to host, scale and manage Web applications on the Internet through Microsoft® data centers”. As a software development outsourcing company, Murano Software has always been on the cutting edge of technology. This has enabled us to develop successful Web-based software solutions quickly and make our customers happy. That’s why we probed into Microsoft’s cloud computing immediately after the initial presentation of Microsoft Windows Azure - Community Technology Preview (CTP). We aimed at designing such a solution that would ensure real-time Web collaboration for multiple users. The solution had to be based on the Windows Azure platform and generalized into a framework. The implementation of this solution gave us a good sense of Windows Azure technologies, capabilities and limitations. 1. Capabilities and limitations of various Azure technologies During the exploration phase of the project, we analyzed the capabilities and limitations of various Azure technologies. The main parts of Microsoft’s Windows Azure platform are the following cloud technologies: - Windows AzureCompute service
- SQL Azure (Learn more)
- .NET Services (Learn more)
The Compute service runs applications and provides two different “instance” (virtual machines) types for developers to use: Web Role Instances and Worker Role Instances. Web Role can accept incoming HTTP and HTTPS requests, but can’t initiate its own request for output. Windows Azure can’t ensure that multiple requests from the same user will be sent to the same Web Role. So the Web Role must be stateless to make an application scalable, and any client-specific state has to be written to Windows Azure storage, SQL Azure or passed back to the client after each request. Worker Role can’t accept requests from the outside. As a rule, it gets input via Queue (see figure 1). Worker Role can send output to outside via Queue or outside connections, and it is used for batch work. Windows Azure storage is exploited to exchange data between different parts of an application, and it provides developers with blobs, tables and queues. Blobs are used to save binary data up to 50 gigabytes. Tables aren’t relational tables. They contain a set of entities with properties. A table has no fixed structure, so one table can contain entities with different amount of properties. Different entities can even have some properties that have equal names, but different types. A single table can hold terabytes of data. Windows Azure storage offers a way to partition a table between many servers to improve performance. It can be done by using different partition keys for different groups of data. The main goal of Queue is to allow communication between different parts of Windows Azure applications. So Queues provide a way for Web Role Instances to communicate with Worker Role Instances. Data that’s part of a Queue’s message can reach up to eight kilobytes, which isn’t much, in fact. 2. Preliminaries (Solution concept) We have to solve several tasks to find a solution that will allow multiple users to cooperate: - What technologies of Windows Azure platform have to be used to process server side work?
- How to notify a user of changes made by other users in a system.
2.1. Technologies of the Windows Azure platform we use Microsoft suggests we use Web Roles only for simple work processing, while Web Roles and Worker Roles should be used in conjunction to process time-consuming work. We decided to implement both variants in our solution to process simple and complex work. Then we implemented a simple mechanism of switching between the two variants, which entrusted a decision on task complexity to a developer. When we use Web Role only, everything is simple. Let’s look at the variant when Web Roles and Worker Roles are used in conjunction (see figure 1). Figure 1. This is the general scheme of the Compute service work originally offered by David Chappell. Sending a lot of data to Worker Role makes Queue vulnerable. We decided to use a blob to save both input and result data for Worker Role. A link to this blob can be saved to Queue. Thus we avoid the Queue’s restriction. Users communicate with Web Role using WCF, so each operation contract in Web role is the work requested by the user. If Web Role carries out simple work then everything is clear. But how will Worker Role know what kind of work it has to perform? Taking into account that our solution has to be generalized into a framework, we decided to implement the following interface: public interface ITask : ICloneable
{
// Date and time of task created
DateTime CreatedDate { get; set; }
// Task’s unique identifier
Guid TaskId { get; set; }
// Property defines usage of background processing
bool IsBackgroundProcessing { get; set; }
// Current state of a task: Success, Skipped, Postponed, Failed, Unknown
TaskState State { get; set; }
// Property used for saving task’s result
object ResultData { get; set; }
// Property used for saving task’s input data
object InputData { get; set; }
// Property used transfering exception, occured while task execution
Exception ExecutionException { get; set; }
// Method defines essence of the task
object Execute();
}
Figure 2. General task interface
Developers have to implement a class that inherits from the interface. Execute method of the class determines work that has to be processed by an application based on our framework.
Using the interface gives us the following advantages:
- A developer needs only to implement any logic in Execute method without any changes in the framework.
- Class can be serialized and sent to Worker Role from Web Role via Queue. Thus any free Worker Role can get the class, deserialize it and run Execute method.
- Implemented class can be performed either by Web Role or Worker Role. A developer can choose which type of Role processes work. The IsBackgroundProcessing property determines what kind of processing has to be done.
Our framework implements various applications to allow multiple users to work together while the code is not changed inside the framework.
Any modern application can’t work without a database. Microsoft provides two types of storages: SQL Azure and Windows Azure storage. Usage of SQL Azure is similar to SQL Server. So Azure storage is more interesting for us as part of the Windows Azure platform. We decided to use Windows Azure storage in our solution. We implemented a mechanism that allows creating tables in Azure storage in the simplest way. This is a BaseEntity class implemented in the framework.
public abstract class BaseEntity : TableServiceEntity
{
protected BaseEntity()
{
CreatedDate = DateTime.UtcNow;
}
public DateTime CreatedDate { get; set; }
protected abstract void RebuildBuildRowKey();
}
A developer only needs to implement his own class that inherits from BaseEntity to determine a table in Azure storage.
public class ShapeEntity : BaseEntity
{
public string ShapeType { get; set; }
public long Color { get; set; }
public double Thickness { get; set; }
public double Opacity { get; set; }
public string XYPoints { get; set; }
public string BoardName { get; set; }
// This method can be overriden to implement
protected override void RebuildBuildRowKey()
{
throw new NotImplementedException();
}
}
A developer implements context that creates all tables.
public class PaintContext : TableServiceContext
{
public const string BoardTable = "Boards";
public const string ShapeTable = "Shapes";
public PaintContext(string baseAddress, StorageCredentials credentials) : base(baseAddress, credentials)
{ }
public IQueryable Boards
{
get { return CreateQuery(BoardTable); }
}
public IQueryable Shapes
{
get { return CreateQuery(ShapeTable); }
}
}
2.2. User notification
The solution that allows multiple users to cooperate has to include a mechanism to notify users of changes. Let’s call any work requested by a user a task. We considered three cases:
- One table is used for all tasks. Each task has a status showing if a task is completed or is in use. Each Web role makes requests to this table and checks the presence of tasks completed. If there is a completed task, then the task’s result is sent back to the user.
- Web Role creates new Queue for each user who makes request to it. The notification “task completed” will be added to all users’ Queues when a task is completed. Web Role checks these Queues to see if there is any notification of a completed task in loop. Web Role gets a link to a blob, which contains result data from the notification and sends it to the user.
- .Net Service Bus can be used to notify users or Web Role of the task’s completion.
We decided include the first and third cases in our solution. The first option is easy to implement, but produces a high load on the Storage Service, while a lot of Web Role Instances are constantly pulling the table. But the table contains all history of performed work. It can be used in a decision-making process about the sequence for the different tasks performing the same actions. Usage of .Net Service Bus is more complex in implementation, but it allows you to notify a user of the task’s completion either directly or through Web Role.
2.3. Other features implemented in the framework
It is worth mentioning that Worker Role is a virtual machine (VM). This VM uses one of the processor’s cores. There may arise a situation when our processor’s core isn’t being used fully. For example, Worker Role is calling outside services, such as the storage service or other services in the Internet, is waiting for a response. The processor is idle while waiting for a response. We implemented a simple mechanism to manage several threads under one Worker Role Instance. It allows you to load Worker Role as much as possible.
3. Overview of solution generalized to framework
Web Role accepts a request and selects one of the classes inherited from the task, depending on the called operation contract. Then the class's TaskId, InputData and IsBackgroundProcessing properties are filled by new Guid, Input data and IsBackgroundProcessing flag from the request. This class is put to a task manager where the class’s properties are saved to the Task table. Then the task manager either runs the class’s Execute method or sends the class to Worker Role.
Let’s look at the case when Web Role runs Execute method by itself. Web Role calls Execute method of the current instance of class and saves the results to a blob. It saves a link to this blob and updates the status into a Task table for the current instance of class. Web Role returns the result data to the user as a result of the called operation contract.
Now, let’s look at the case of using background processing. Task Manager saves the class’s InputData to a blob with the name “InputData”+TaskId, and a link to that blob is saved to Queue with the serialized instance of the class. Any free Worker Role gets a serialized class from Queue, deserializes it and fills Input data from the blob. Then Worker Role calls Execute method of the class. The results of Execute method working are saved to a blob with the name “ResultData”+TaskId. A link to the blob and the status “Task completed” are saved to the Task table. Web Role checks the Task table in loop and returns the results from the blob when the status of class has changed to completed state.
The other way of notification is using.Net Service Bus by Web Role. In this case, Worker Role, which is to be notified of class’s Execute method completion, creates a request to Service Bus. .Net Service Bus raises an event when the class’s Execute method has finished work, and all Web Role Instances subscribed to the event have been notified. Notified Web Role gets results from the blob and sends it to the customer. An address to the blob is stored to notification. If Web Role expects some results data, but there isn’t any data to return to the user, Web Role puts the class to Worker Role to repeat the performance.
We have investigated the case when only one of the collaborating users makes a request to Web Role to do some work and is notified of the task's completion. But other users have to be notified of changes made by the requested work, too.
There are three options that can be used by a developer:
- A developer can implement an individual operation contract in WCF that checks the Task table and returns all changes if there are any in loop.
- A developer can use .Net Service Bus for notification of users directly.
- A developer can implement a class that inherits from ITask. This class can take results requested by the user using some processing.
In the second case, users subscribe to event from .Net Service Bus. This event is raised if there are any changes in the system made by other users. The changes can be transmitted either inside event arguments or via calling the individual operation contract in WCF. So a developer can implement any algorithm of getting concrete results.
You can see the architecture of a scalable cloud application based on our framework in figure 4, as well as the sequence diagram in figure 3.
Figure 3. Sequence diagram shows processing of user’s request using Service Bus.
Figure 4. Architecture of a scalable cloud application based on our framework
The main framework capabilities are as follows. The workflow of performing any work depends on a scenario selected by a developer and can be expanded to achieve more complex goals. The flexibility of the workflow is controlled by the properties determined in the ITask interface. The rest of the logic and code remain the same for different kinds of goals. The behavior depends only on the type of the class inherited from ITask that is created in Web Role for each particular client request. Usage of .NET Service Bus adds flexibility to the Silverlight Client – Web Role communication.
Our solution for user notification is an alternative to polling duplex for Windows Azure platform, which was in a stage of development at that moment.
Demo applications
To show our framework in action, we implemented a cloud application that allows multiple users to draw many-colored shapes on the same board. Each user can see the changes made by others. It’s a real-time collaborative drawing cloud application, using Silverlight and Microsoft Windows Azure, and you are welcome to test-drive it at http://multidraw.cloudapp.net. The framework can be easily adapted for any similar task. A good sample of an application that can be created with the help of our architecture is a multi-edit grid that allows a multiuser edition of the same grid. You can see the demo at http://multidraw.cloudapp.net/grid/SomeSession.

Figure 5. Screenshot of Multidraw application working in different browsers
Conclusion
We looked into new implementation of cloud computing presented in the Windows Azure platform by Microsoft. We developed a universal framework architecture that allows you to implement similar tasks with multiple-user interaction easily. We implemented working prototypes that allow multiple users to draw many-colored shapes on the same board and edit the same grid.
By Alexander, a Senior Java/PHP Developer on Murano Software’s team CSS3 features are really good for implementing modern UI tendencies, such as rounded corners, shadows and transparency. Today, most browsers support CSS3 or provide their own ways to achieve the same features. Let's review the most popular CSS3 features. Round corners Round corners were a pain for a lot of developers, since border radius is not supported by all browsers. Most often, images and techniques like "sliding doors" were used. For IE, we can use VML to emulate border radius support. Actually, it is already implemented by Remiz Rahnas and Nick Fetchak as tiny IE behavior. So we are downloading border-radius.htc, putting it in the CSS directory and simply including it in our CSS rule: .my-block {
background: #000; color: #fff;
-moz-border-radius: 10px; /* Firefox */
-webkit-border-radius: 10px; /* Safari, Chrome */
-khtml-border-radius: 10px; /* KHTML */
border-radius: 10px; /* Opera 10.50 beta and other CSS3 compatible browsers */
/* for IEs */
behavior: url(border-radius.htc); /* teaching IE to understand border-radius */
}
Box shadows
Box shadows were even worse than rounded corners. There were some good techniques to achieve a flexible box shadow solution, but most of them were too complicated.
In addition to implementing IE behavior for round corners, Remiz Rahnas and Nick Fetchak made another one for box shadows. So, to support box shadow in IEs, you need to download ie-css3.htc and include it in the CSS rule:
.my-block {
background: #fff; color: #000;
-moz-box-shadow: 10px 10px 10px #000; /* Firefox */
-webkit-box-shadow: 10px 10px 10px #000; /* Safari, Chrome */
-khtml-box-shadow: 10px 10px 10px #000; /* KHTML */
box-shadow: 10px 10px 10px #000; /* Opera 10.50 beta and other CSS3 compatible browsers */
/* for IEs */
behavior: url(ie-css3.htc); /* teaching IE to understand border-radius and box-shadow */
}
Opacity
Opacity is another property often used by designers to put some fancy semi-transparent labels on images or do something similar. The problem is, again, that Internet Explorer does not support alpha transparency directly. The solution is to use a filter:
.my-block {
opacity: .5; /* CSS3 compatible browsers */
filter: alpha(opacity=50); /* IE < 8 */
-ms-filter: "alpha(opacity=50)"; /* IE 8 */
-khtml-opacity: .50; /* KHTML */
-moz-opacity: .50; /* Firefox */
}
RGBA
The problem with opacity is that it cascades. So, for example, it does not fit if you need nontransparent text inside a semi-transparent box. RGBA comes to the rescue here. RGBA is a way to specify color by component: red, green, blue and (the sweet part!) alpha transparency. Here we'll need to use IE conditional comments to apply some styles exclusively to IE.
This one is for all browsers. If a browser does not support rgba, rgb will be used:
.my-block {
background: rgb(255, 255, 255);
background: rgba(255, 255, 255, .5);
}
This one is for IEs:
.my-block {
background: transparent;
filter:progid:DXImageTransform.Microsoft.gradient(startColorStr=#7FFFFFFF,endColorStr=#7FFFFFFF); // IE<8
-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#7FFFFFFF,endColorstr=#7FFFFFFF)"; // IE8
zoom: 1; // triggering hasLayout to avoid block problems
}
Here we are using a gradient filter that accepts two RGBA values in format #AARRGGBB as start color and end color. AA is the hex transparency value, while RR, GG and BB are hex color components. rgba(255, 255, 255, .5) equals #7FFFFFFF: 0.5 * 255 = 127 (truncated) that is 7F in hex. For RR, GG and BB, we are just converting component value to hex.
By Alexander, a Senior Java/PHP Developer on Murano Software’s team Facebook, as you may already know, is working to open source their PHP to C++ translator, called HipHop. There is a lot of buzz about it, so I think a summary will be handy. Main points: - It's free and open source.
- HipHop is already used by Facebook, so it's tested with their huge code base.
- Process is: PHP → С++ → GCC → binary.
- HipHop is not JIT. You should translate and compile all code on every deployment.
- Binary can work as standalone server (using libevent). Also, it can work in command line.
- Standalone server uses one process and many threads.
- It's not based on Zend Engine. Instead, C++ code compatible with PHP 5.2 is used.
- Extensions are converted to thread-safe C++ (standard PHP extensions are being developed in C).
- Many extensions already have been converted. These are used by Facebook.
- If you want to use HipHop, prepare to convert additional extensions yourself.
- Some PHP magic methods are supported, but the performance is the same as in PHP.
No support for: - Windows.
- PHP 5.3 (will be implemented later).
- eval().
- create_function().
- preg_replace with /e modifier.
- function_exists() before function declaration.
Dynamic PHP functionality supported: - Dynamic function call including call_user_func().
- Dynamic methods and properties.
- Dynamic variables, extract().
- Dynamic include().
- Redefinition of functions, classes and constants.
- __toString(), __get(), __set(), __call().
Thoughts: Facebook made a great tool to make their codebase run faster without rewriting it in C or C++. They do have a reason for it, and there is no doubt they (with their really high loads) need it. What does it mean for the rest of us? A little. All major PHP frameworks and CMS, including Drupal and Wordpress, cannot be compiled by HipHop. Moreover, PHP execution itself is a bottleneck in a very few cases, like Facebook’s, where data storage and other infrastructure is perfectly optimized. If your application works slowly, and you aren't getting loads comparable to Facebook’s, HipHop most likely will not help you. The problem is within the database or algorithms used. Sources used:
|