Java Development 2.0

Source: Internet
Author: User
Tags joins web services couchdb value store

Java Development 2.0-using Amazon SimpleDB for cloud storage, part 1th-Starting with the SimpleDB and Amazon SDK

Throughout the series, I have shared with you a large number of non-relational data stores, collectively known as NoSQL. In a recent article, I showed you a huge difference between a document-oriented data store (CouchDB) and a schema-oriented relational database. In addition, the entire API for CouchDB is restful and supports different ways of querying: the MapReduce functionality defined in JavaScript. Obviously, this is a great breakthrough for traditional JDBC.

I've also recently written about Google's Bigtable-related content, which is not a relational or document-oriented data solution (and it occasionally does not support JDBC). Bigtable is the so-called key/value store. In other words, it is modeless and generally supports anything you store, whether it's a parking ticket instance, a list of matches, or a contestant in a race. The modeless form of Bigtable provides a lot of flexibility and therefore supports rapid development.

Bigtable is not the only key/value data store that we can choose from. Amazon has its own cloud-based key/value storage Amazon SimpleDB. Bigtable is publicly available to Java developers through an abstraction provided by Google App Engine, and Amazon SimpleDB is exposed through the Web service interface. Therefore, you can SimpleDB data storage through web and HTTP operations. The binding on Amazon's Web Service infrastructure allows us to choose our own language to use SimpleDB, including PHP, Ruby, C #, and the Java language.

This month, I'll introduce you to SimpleDB through Amazon's official SDK. I'm going to use another game-related example to showcase this powerful, cloud-based data store on a much different side: Dictionary search.

SimpleDB Introduction

At the bottom, SimpleDB is a highly available data store that can be scaled up and written in Erlang. Conceptually, it's like Amazon's S3. But S3 has objects in bucket, and SimpleDB is logically defined as the domain that contains the project. SimpleDB also allows items to contain properties. Consider a field as a table in a bucket or relational sense in S3 (or, more accurately, Bigtable "kind" concept). Note, however, that you should not project relationships into the concept of SimpleDB, as it will eventually become modeless like Bigtable. A field can have more than one item (similar to a row), and a project can have more than one property (similar to a column in a relational table).

SimpleDB's ' final consistency '

CAP theorem shows that a distributed system cannot be highly available, scalable, and consistent at the same time; indeed, a distributed system only supports two of these three traits at any one time. Accordingly, SimpleDB ensures a highly available, scalable data store, but does not support instant consistency. SimpleDB supports final consistency, which is not as bad as you might think.

For Amazon, final consistency means that everything becomes consistent within a few seconds of all nodes (but within a single region). During this short period of time, two concurrent processes may read two different instances of the same data, and in the meantime you are in exchange for mass reliability and an affordable price. (You only need to ask a commercial entity that provides similar reliability to see the difference.) )

property is a real name/value pair (a bit like Bigtable, isn't it?) and "yes" is not limited to one value. That is, an attribute name can have a collection of related values (or lists); For example, a word item can have multiple-defined attribute values. In addition, all data within the SimpleDB is represented as a string, which is significantly different from Bigtable or even an RDBMS, which typically supports mixed data types.

SimpleDB's single data type attribute value method has pros and cons, depending on how you look at it. Whether it's pros or cons, it does imply how the query works (more about it soon). SimpleDB also does not support the concept of Cross-domain joins, so you cannot query items in multiple domains. However, you can overcome this limitation by executing multiple SimpleDB and performing joins at your end.

The project itself does not have a primary key (just like Bigtable). The primary key or unique identifier for an item is the name of the project. SimpleDB is smart enough to update an item when a copy creation request is made, as long as the item's properties have been changed.

Like other Amazon Web Services, SimpleDB exposes everything through HTTP, so there are many ways to interact with it. In Java, our options are from Amazon's own SDK (which we'll use in the next example) to a popular project called Topica, even to a mature JPA implementation (which we'll explore in the 2nd part).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.