Skip to main content

· 6 min read

Working with the Couchbase 2.0.0 release you may have issues when trying to access the Web Admin Console or simply starting the server. This is due to the way Couchbase Server uses the IP address/hostname during the installation process. So when you have one of the following errors :

  • On Windows, Server is not working at all, even after installation. You can access the sever on port 8092 (Couchbase API port), but cannot on port 8091
  • You have the following error when accessing the console "[10:02:02] IP address seems to have changed. Unable to listen on 'ns_1@10.0.2.15'"

  • When you try to restart the server it does not start and you have the following error message in the error log : "Configured address '10.0.2.15' seems to be invalid. Will refuse to start for safety reasons"

Some of these issues are related to a known issue on Windows ( see MB-7417 that will be fixed in 2.0.1) or the fact that Couchbase server does not support change of the IP address after installation. This is documented in the section “Using Couchbase in the Cloud: Handling Changes in IP Addresses” of the Couchbase Server Manual. This article explains what should be done when configuring Couchbase Server on Windows, but you can do equivalent steps on any platform using the shell scripts available on Linux and/or Mac OS X.

Once you have installed Couchbase, you can see in the console that the IP address of your server is used :

Typically the address 192.168.0.97 is stored in the configuration of Couchbase. If your server receives a new address from the DHCP server, Couchbase will not work anymore. In this article you will see how you can configure Couchbase to use another IP address or Hostname.

Important: The steps that follow will completely destroy any data and configuration from the node, so it is best to start with a fresh Couchbase install. If you can not, you should backup your data using the file based backup-restore documented here.

· 2 min read

Yesterday was my last day at eXo... I have been working at eXo since 2008, and we have achieved many exciting things such as building eXo Platform, the open source social platform, and the Cloud-IDE allowing developers to build, test, and deploy applications online.

It was a great experience for me, but it is time for me to jump into a new adventure...

I am joining Couchbase as a Technical Evangelist for the EMEA Region. When I have started to work with NoSQL engines (starting with Google BigTable for Resultri) I really enjoyed the experience and the flexibility that it gives to the developers. Then I choose to work on a documented oriented database because it looks very natural to me, and evaluate the clustering capabilities. This is how I discovered Couchbase and its community.

This new job is a great opportunity for me to do the things that I really like about software:

  • Coding applications using different languages and frameworks
  • Understanding the sysops/devops related challenges when using a new product/technology
  • And finally probably the most important part; sharing it with others!

I look forward to sharing what I like about NoSQL and Couchbase and discuss with others about their experience or needs around NoSQL. 

See you soon online and in real life during conferences and meetups!

Couchbase Logo

· 4 min read

An easy way to create large dataset when playing/demonstrating Couchbase -or any other NoSQL engine- is to inject Twitter feed into your database.

For this small application I am using:

In this example I am using Java to inject Tweets into Couchbase, you can obviously use another langage if you want to.

The sources of this project are available on my Github repository Twitter Injector for Couchbase you can also download the Binary version here, and execute the application from the command line, see Run The Application paragraph. Do not forget to create your Twitter oAuth keys (see next paragraph)

Create oAuth Keys#

The first thing to do to be able to use the Twitter API is to create a set of keys. If you want to learn more about all these keys/tokens take a look to the oAuth protocol : http://oauth.net/

1- Log in into the Twitter Development Portal : https://dev.twitter.com/

2- Create a new Application

Click on the "Create an App" link or go into the "User Menu > My Applications > Create a new application"

3- Enter the Application Details information

4- Click "Create Your Twitter Application" button

Your application's OAuth settings are now available :

5- Go down on the Application Settings page and click on the "Create My Access Token" button

You have now all the necessary information to create your application:

  • Consumer key
  • Consumer secret
  • Access token
  • Access token secret

These keys will be uses in the twitter4j.properties file when running the Java application from the command line

Create the Java Application#

The following code is the main code of the application:

Some basic explanation:

  • The setUp() method simply reads the twitter4j.properties file from the classpath to build the Couchbase connection string.
  • The injectTweets opens the Couchbase connection -line 76- and calls the TwitterStream API.
  • A Listener is created and will receive all the onStatus(Status status) from Twitter. The most important method is onStatus() that receive the message and save it into Couchbase.
  • One interesting thing : since Couchbase is a JSON Document database it allows your to just take the JSON String and save it directly. cbClient.add(idStr,0 ,twitterMessage);

Packaging#

To be able to execute the application directly from the Jar file, I am using the assembly plugin with the following informations from the pom.xml:

  ...<archive><manifest><mainclass>com.couchbase.demo.TwitterInjector</mainclass></manifest><manifestentries><class-path>.</class-path></manifestentries></archive>...

Some information:

  • The mainClass entry allows you to set which class to execute when running java -jar command.
  • The Class-Path entry allows you to set the current directory as part of the classpath where the program will search for the twitter4j.properties file.
  • The assembly file is also configure to include all the dependencies (Twitter4J, Couchbase client SDK, ...)

If you do want to build it from the sources, simply run :

mvn clean package

This will create the following Jar file ./target/CouchbaseTwitterInjector.jar

Run the Java Application#

Before running the application you must create a twitter4j.properties file with the following information :

twitter4j.jsonStoreEnabled=true
oauth.consumerKey=[YOUR CONSUMER KEY]oauth.consumerSecret=[YOUR CONSUMER SECRET KEY]oauth.accessToken=[YOUR ACCESS TOKEN]oauth.accessTokenSecret=[YOUR ACCESS TOKEN SECRET]
couchbase.uri.list=http://127.0.0.1:8091/poolscouchbase.bucket=defaultcouchbase.password=

Save the properties file and from the same location run:

jar -jar [path-to-jar]/CouchbaseTwitterInjector.jar

This will inject Tweets into your Couchbase Server. Enjoy !

· 7 min read

NOTE: The Couchbase Node.js Client Library is currently changing. I will update this article and source code once the API is stable.

I am currently playing a little bit with Node.js . It is quite fun! In this article I won't go in a a very complex application but just give you the basic steps to create your first Node.js+Couchbase application... on Mac OS X.

Installation#

Couchbase 2.0 Beta:

You can take a look the first steps of my previous article to install Couchbase. The basics steps are:

  • Download Couchbase 2. 0 Beta
  • Start the server (Run the "Couchbase Server" application)
  • Configure the server

Other Components :

  • Node.js
  • Couchbase Client Library (C version)

· 8 min read

Introduction#

In this post I just want to show how easily is to get started with Couchbase, and also explain how to “query” the data. The basic steps of this tutorial are:

  1. Install Couchbase
  2. Create Data
  3. Query Data

I will try to post more articles, if I have time to show how to use Couchbase from your applications (starting with Java).

Prerequisites :

  • Could not be simpler : Couchbase 2.0 available here. (Currently in Developer Preview)

Couchbase 101 : Insert and Query data#

Installation#

I am using Couchbase on Mac OS X, so let me describe the installation in this environment. If you are using other operating system just take a look to the Couchbase documentation.

Couchbase installation is very (very!) fast:

  1. Download the Mac OS X Zip file.
  2. Double-click the downloaded Zip installation file to extract the contents. This will create a single file, the Couchbase.app application.
  3. Drag and Drop the Couchbase.app to your chosen installation folder, such as the system Applications folder.

Start and Configure Couchbase Server#

To start Couchbase Server, just double click on the Couchbase Server. Once the server is started, a new icon is added in the OS X Menu to indicate that the Server is up and running.

You can now configure your Couchbase instance, for this you just need to access the Admin Console, available at the following location http://127.0.0.1:8091 (change the IP address if needed) or simply by going in the Couchbase menu and click on Open Admin Console entry.

  1. Welcome Screen : Click Setup
  2. Set the disk and cluster configuration. On my instance I keep the default location for the on disk storage. Just configure the size of the memory usage for your instance, for example 800Mb. So far, we have a single instance, so no need to join a cluster.
  3. Choose to generate sample data. This will be interesting to learn more about data and views.
  4. Create the default bucket (use for testing only). A bucket is used by Couchbase to store data. It could be compared to a “database” in RDBMS world.
  5. Configure update notifications to be alerted when new version of Couchbase is released
  6. Configure the server with a final step with the administrator username and password
  7. When this is done you are automatically redirected to the Admin Console.

This is it! You are ready to use your Couchbase server.

Couchbase has many interesting features, especially around scalability and elasticity but for not in this article let's focus on the basics :

  • Insert some data and query them

Insert Data#

Couchbase has many ways to manipulate data from you favorite programming language using the different client libraries : Java, Python, PHP, Ruby, .Net, C. For now let's use the Admin Console to create and query data.

Couchbase can store any type of data, but when you need to manipulate some data with a structure the best way is to use JSON Documents. So let's use the console and create documents.

To create new documents in your database, click on the "Data Buckets" tab. If you have installed the sample you see 2 buckets: default and gamesim-sample.

Let's create a new documents in the default bucket:

  1. Click on Documents button
  2. Click on Create Document
  3. Since each document must have an id for example 100.
  4. Couchbase save the document and add some metadata such as _rev, $flags, expiration
  5. Add new attributes to the document that describe an employee : Name, Departement and Salary, then save it. You just need to update the JSON object with values
{      "_id": "100",      "name": "Thomas",      "dept": "Sales",      "salary": 5000  }

Repeat the operation with some other employees :

  200,Jason,Technology,5500  300,Mayla,Technology,7000  400,Nisha,Marketing,9500  500,Randy,Technology,6000  501,Ritu,Accounting,5400

You have now a list of employees in your database. That was easy isn't? Let's now query them.

Query Data#

Access document directly from its ID

First of all you can quickly access a document using a simple HTTP request using its id. For example to access the Mayla with the id 300 just enter the following URL:

  • http://127.0.0.1:8092/default/300

In this URL you have :

  • 8092 is the Couch API REST port used to access data (where 8091 is the port for the Admin console)
  • default is the bucket in which the document is stored
  • 300 is the id of the document

Search your data with queries#

So we have seen how you can access one document. But what if my need is :

  • "Give me all the employee of the Technology department"

To achieve such query it is necessary to create views. The views are used by Couchbase server to index and search your data. A view is a Map function written in JavaScript, that will generate a key value list that is compliant with logic you put in the Map function. Note that this key,value is now indexed and sorted by key. This is important when you query your data.

So let's create a new view from the Admin Console:

  1. Click on the Views tab (be sure you are on the default bucket)
  2. Click on the "Create Development View"
  3. Enter the Document and View name:
  • Document Name : _design/dev_dept
  • View Name : dept
  1. Cick Save
  2. Click on your View to edit it

Since we need to provide the list of employees that are part of a the Technology department, we need to create a view that use the department as key, so the map function looks like :

function (doc) {    emit(doc.dept, null);}

Save the view

This function takes the document and create a list that contains the "dept" as key and null as value. The value itself is not that important in our case. A simple rule will be : do not put too much data in the value since at the end Couchbase server creates an index with this map. Will see that Couchbase allows developer to easily get the document information when accessing a view.

Click on the "Show Results" button, the result will look like:

{"total_rows":6,"rows":[  {"id":"501","key":"Accounting","value":null},  {"id":"400","key":"Marketing","value":null},  {"id":"100","key":"Sales","value":null},  {"id":"200","key":"Technology","value":null},  {"id":"300","key":"Technology","value":null},  {"id":"500","key":"Technology","value":null}  ]}

As we have seen in earlier it is possible to access the document using a single URL, it is the same for views. You can for example access the view we have just created using the following URL:

Now it is possible to use query parameter to filter the results using the key parameter with the value entered using a JSON String :

The result of this query is now :

{"total_rows":6,"rows":[  {"id":"200","key":"Technology","value":null},  {"id":"300","key":"Technology","value":null},  {"id":"500","key":"Technology","value":null}  ]}

You have many other parameters you can use when accessing a view to control the size, the time out, .... One of them is quite interesting is include_docs that ask Couchbase to include the full content of the document in the result. So if you call :

The result is :

{"total_rows":6,"rows":[  {"id":"200","key":"Technology","value":null,"doc":  {"_id":"200","_rev":"1-1de6e6751608eada0000003200000000","$flags":0,"$expiration":0,"name":"Jason","dept":"Technology","salary":5500}},  {"id":"300","key":"Technology","value":null,"doc":{"_id":"300","_rev":"1-f3e44cee742bfae10000003200000000","$flags":0,"$expiration":0,"name":"Mayla","dept":"Technology","salary":7000}},  {"id":"500","key":"Technology","value":null,"doc":  {"_id":"500","_rev":"1-05780359aac8f3790000003200000000","$flags":0,"$expiration":0,"name":"Randy","dept":"Technology","salary":6000}}]}

Let's now create a little more complicated view to answer the following business requirement:

  • "Give me all the employee with a salary between 5000 and 6000"

So now you know that you need to create a new view with the salary as key let's with the following Map function:

function (doc) {  emit(doc.salary, null);}

Couchbase is automatically sorting the key when creating/updating the index so, let's use the startkey and endkey parameter when calling the view. So let's call the view with from the following URL:

The result is :

{"total_rows":6,"rows":[ {"id":"100","key":5000,"value":null,"doc":{"_id":"100","_rev":"1-0f33580d780014060000002e00000000","$flags":0,"$expiration":0,"name":"Thomas","dept":"Sales","salary":5000}}, {"id":"501","key":5400,"value":null,"doc":{"_id":"501","_rev":"1-b1fe5bc79637720e0000003100000000","$flags":0,"$expiration":0,"name":"Ritu","dept":"Accounting","salary":5400}}, {"id":"200","key":5500,"value":null,"doc":{"_id":"200","_rev":"1-1de6e6751608eada0000003200000000","$flags":0,"$expiration":0,"name":"Jason","dept":"Technology","salary":5500}}, {"id":"500","key":6000,"value":null,"doc":{"_id":"500","_rev":"1-05780359aac8f3790000003200000000","$flags":0,"$expiration":0,"name":"Randy","dept":"Technology","salary":6000}}]}

Conclusion#

In this short article you have learn how to:

  • Install Couchbase* Create data using the Admin Console
  • Query data with views

When I get more time I will write another article that do the same from Java, and other languages.


Note from @ingenthr

Nice blog! Note that while querying the REST interface directly is okay, we've really tried to make it easy by having high-level language support for queries in each of the official client libraries. They're all listed over at http://www.couchbase.com/develop

· One min read

In this screencast I explain the support of multi-lingual content of eXo Platform 3.5. The different features that you can see in this video are:

  • Support of multiple languages from URL
  • Configure the eXo File Explorer to add support for multi-lingual content (new button)
  • Content translation
  • Add new language to the platform

· One min read

Like many developers I am using Twitter Boostrap for my Web applications. Using this framework has been very helpful for me, since I am really not a good HTML/CSS developer. For now, on my site Resultri I am using the default look and feel, will customize it later.

Lately, I wanted to integrate Google Map to my application, and when testing it, I had the bad surprise to see that the Controls and WindowInfo are not printed correctly as you can see in the screen shot below:

This is not a big issue at all, just a conflict on the img tag and its style (max-width) coming from Twitter Bootstrap. The quick fix :

  • override the style of the img tag for the div that contains your map.

For example in my case the div for my map is define as:

<div id="resultriMap" />

You just need to add a new style to your page with the following definition:

<style>
#resultriMap img {    max-width: none;}
</style>

After adding this to my page the map is correctly printed as you can see in the following screenshot :

· One min read

Last week I was invited to present eXo Cloud IDE during the SAP Cloud Inside. This SAP Community event was a great opportunity to discuss about the cloud with an interesting point of view: the impact of the cloud for SAP customers (especially administrators and developers).

During this presentation I have introduced the eXo Cloud IDE, and I did a demonstration in which O have built and deployed applications : Open Social Gadgets, Ruby on Rails and Java/Spring, and explain how it could be extended to SAP business services.

Here the slides that I have used during this presentation:

SAP Cloud Inside : Develop and Run on the Cloud

Remember that you can register yourself to the eXo Cloud IDE Service and start develop application from your browser.

· One min read

eXo Platform 3.5 provides many extension points and API for developers, allowing them to create very cool stuff.

I have developed a small extension that allows any user to associate his Twitter account to his eXo Platform account. This extension simply post on your Twitter account when you write a message with a special hashtag (#tw).

This is a very quick development that I have done while waiting for my kids, so I still have things to integrate to provide complete feature, but this is a good example to show how you can extend the platform.

You can view it in action in this video:

You can download the source code and the binaries from this GitHub project. I hope to find some time to complete the feature, and document this use case.

Enjoy!

· One min read

Lately I have been traveling a lot, and I was not able to access the internet all the time; but I still want to look at some YouTube video, for example the greate Google I/O Sessions...

My needs are simple :

  • running on OS X (Lion)
  • download the video easily
  • no need to convert the file (to be able to read the file as soon as possible)
  • free

After some basic research, I found an easy way to achieve this using the following softwares:

Enjoy!