Multi-Nodes Redis Cluster With Docker

Go to the complete article here.

| db_host = xxxxxxxx.couchbase.clvrcld.net | Location of the database, this is where the endpoint is located. |
| db_name = yyyyyyyy | Name of the Couchbase bucket |
| db_username = xxxxxxxx | Not used in Couchbase context |
| db_password = zzzzzzzz | Password to connect to the Couchbase Bucket |
git clone -b 03-vote-with-value https://github.com/tgrall/couchbase-node-ideas.git
cd couchbase-node-ideas
git branch mybranch git checkout mybranch
npm install
dbConfiguration = {
"hosts": ["xxxxxxxxxxx.couchbase.clvrcld.net:8091"],
"bucket": "xxxxxxxxxxx",
"user": "xxxxxxxxxx",
"password": "yyyyyyyyyyyyyyyyyyyyyyyyy"
};
...
...
appServer = app.listen(8080, function() {
console.log("Express server listening on port %d in %s mode", appServer.address().port, app.settings.env);
});
node app.js
git remote add clever git+ssh://git@push.clever-cloud.com/app_[your_app_id].git
git commit -a -m “Couchbase on Clever Cloud connection”
git push clever mybranch:master
Posted by
Tug Grall
at
5:47 AM
0
comments
Labels:
clevercloud,
Cloud,
couchbase,
node
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:
Posted by
Tug Grall
at
11:56 PM
0
comments
Labels:
Cloud,
conference,
exo,
IDE
Introduction
Many Google
AppEngine developers have been waiting for the Full Text Search feature,
especially coming from Google the biggest search engine on the Web. I
was quite happy to see that Google team is working on it as you can
check in the Google I/O 2011 session : Full Text Search by Bo Majewski, Ged Ellis . As far as I know the very promising indexing service is not yet available.
In
this article I will explain how you can provide some kind of full text
search in your application using services available App Engine services.
In
my specific use case I do not ask for a lot of feature, I just need to
have simple search a string in various attributes of my entities
independently of the case, and possible special characters (such as è,é,
... ). I am far of being an expert of Google Datastore API but I did
not find any simple way to achieve this directly using the Java API.
What I have done to solve this issue is to duplicate a part of my data
into the Google Cloud SQL to use the MySQL fulltext search capabilities.
Prerequisites
To achieve the following tasks you need to :
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
//...
//...
Entity article = new Entity("Article");
article.setProperty("title", "MySQL Tutorial");
article.setProperty("body", "DBMS stands for DataBase ...");
datastore.put(article);
article = new Entity("Article");
article.setProperty("title", "Datastore Index Selection and Advanced Search");
article.setProperty("body", "Learn how recent improvements to the query planner ... function in your application");
datastore.put(article);
CREATE SCHEMA search_values DEFAULT CHARACTER SET utf8 ; USE search_values; CREATE TABLE articles ( entity_key varchar(250), title text, body text, PRIMARY KEY RESULTS_PK (entity_key), FULLTEXT (title,body) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;Lines 1 and 3 are here to create the database schema and use it; then the script create a table that will contain a copy of the title and body from the entity.
/lib/impl/. You can download the MySQL JDBC driver here. -Drdbms.server=local -Drdbms.driver=com.mysql.jdbc.Driver -Drdbms.url=jdbc:mysql://localhost:3306/search_values?user=username&password=password
lib/impl, and select the JDBC driver JAR file. Click
Open. The driver JAR is listed under User
Entries. Connection conn = null;
try {
DriverManager.registerDriver(new AppEngineDriver());
conn = DriverManager.getConnection("jdbc:google:rdbms://[your db instance]/search_values");
conn.setAutoCommit(false);
String statement = "REPLACE INTO articles (entity_key, title, body) VALUES( ? , ? , ? )";
PreparedStatement stmt = conn.prepareStatement(statement);
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Query q = new Query("Article");
PreparedQuery pq = datastore.prepare(q);
// loop on each entity and insert the values in the SQL Table
for (Entity result : pq.asIterable()) {
stmt.setString(1, KeyFactory.keyToString(result.getKey()) );
stmt.setString(2, result.getProperty("title").toString() );
stmt.setString(3, result.getProperty("body").toString() );
stmt.executeUpdate();
conn.commit();
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (conn != null)
try {
conn.close();
} catch (SQLException ignore) {}
}
public IterablesearchEntity(String query) { List results = new ArrayList (); Connection conn = null; try { DriverManager.registerDriver(new AppEngineDriver()); conn = DriverManager.getConnection("jdbc:google:rdbms://[your db instance]/search_values"); String statement = "SELECT entity_key FROM articles WHERE MATCH (title,body) AGAINST (? WITH QUERY EXPANSION);"; PreparedStatement stmt = conn.prepareStatement(statement); stmt.setString(1, query); ResultSet rs = stmt.executeQuery(); while (rs.next()) { String keyAsString = rs.getString(1); Entity article = DatastoreServiceFactory.getDatastoreService().get( KeyFactory.stringToKey(keyAsString) ); results.add(article); } } catch (SQLException e) { e.printStackTrace(); } catch (EntityNotFoundException e) { e.printStackTrace(); } finally { if (conn != null) try { conn.close(); } catch (SQLException ignore) {} } return results; }
|
One Column View |
Two Columns View |
<h1>This is my template</h1> The date is <= new Date()>
// import all the classes need in the template
import javax.jcr.Node;
import org.exoplatform.wcm.webui.paginator.UICustomizeablePaginator;
import org.exoplatform.wcm.webui.clv.UICLVPortlet;
import org.exoplatform.wcm.webui.Utils;
import org.exoplatform.services.wcm.core.NodeLocation;
// get the portlet preferences
def header = uicomponent.getHeader();
def isShowRssLink = uicomponent.isShowRssLink();
def isShowHeader = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_HEADER);
def isShowRefresh = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_REFRESH_BUTTON);
def isShowTitle = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_TITLE);
def isShowDate = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_DATE_CREATED);
def isShowLink = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_LINK);
def isShowReadmore = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_READMORE);
def isShowImage = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_ILLUSTRATION) ;
def isShowSummary = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_SUMMARY);
The uicomponent object is defined by the container class of the portlet that calls the template. This class contains many utility methods. In the code above I retrieve all the preferences of the portlet, since the name are self-explanatory it is not necessary to detail them, especially when you look at the preferences screen below:
def itemName = viewNode.getName();
def itemLink = uicomponent.getURL(viewNode);
def webdDavLink = uicomponent.getWebdavURL(viewNode);
def itemDateCreated = uicomponent.getCreatedDate(viewNode);
def itemModifiedDate = uicomponent.getModifiedDate(viewNode);
def itemAuthor = uicomponent.getAuthor(viewNode);
def imgSrc = uicomponent.getIllustrativeImage(viewNode);
def itemTitle = uicomponent.getTitle(viewNode);
def itemSummary = uicomponent.getSummary(viewNode);
One important point is the fact that these methods are responsible of many things, for example: formatting dates, returning complete URLs depending of the context of the portlet.
<%
for (viewNode in uicomponent.getCurrentPageData()) {
def itemName = viewNode.getName();
def itemLink = uicomponent.getURL(viewNode);
def webdDavLink = uicomponent.getWebdavURL(viewNode);
def itemDateCreated = uicomponent.getCreatedDate(viewNode);
def itemModifiedDate = uicomponent.getModifiedDate(viewNode);
def itemAuthor = uicomponent.getAuthor(viewNode);
def imgSrc = uicomponent.getIllustrativeImage(viewNode);
def itemTitle = uicomponent.getTitle(viewNode);
def itemSummary = uicomponent.getSummary(viewNode);
%>
$itemTitle
$itemSummary
<%
}
%>
For simplicity reason, this code does not manage any null value. Also the template do not deal with the portlet preferences such as the "Header", "RSS" links and so on, do not hesitate to do it if you want.
The Web site should look like the following image:
<%
for (viewNode in uicomponent.getCurrentPageData()) {
def itemName = viewNode.getName();
def itemLink = uicomponent.getURL(viewNode);
def webdDavLink = uicomponent.getWebdavURL(viewNode);
def itemDateCreated = uicomponent.getCreatedDate(viewNode);
def itemModifiedDate = uicomponent.getModifiedDate(viewNode);
def itemAuthor = uicomponent.getAuthor(viewNode);
def imgSrc = uicomponent.getIllustrativeImage(viewNode);
def itemTitle = uicomponent.getTitle(viewNode);
def itemSummary = uicomponent.getSummary(viewNode);
%>
<%=uicomponent.addQuickEditDiv("MyTemplateContentEditor", viewNode)%>
$itemTitle
$itemSummary
< /div>
<%
}
%>
The lines 15 and 19 are new in this template and provide support for Quick Edit feature.
Done! We have created a new template for eXo Platform Content Service using embedded IDE.
In this article you have learned how to create a new template for eXo Content Service, with some basic steps:
You can now create your own templates and use your imagination to add cool features to your site (for example the carrousels you see on the eXo site are using custom CLV template.)
Yesterday, eXo has launched a new cloud based service: the eXo Cloud IDE. This IDE is an online service that facilitates the development of gadgets and mashups that could be deployed directly to a PaaS.
Before launching this service on the Cloud we, eXo team and customers, have used the IDE embedded in the eXo Platform to extend our intranet and customer deployments (some of the modules that we have developed live on our intranet are available as plugins on the eXo Resource Center).
This IDE is the last mile between the users and the developers. It provides a way to add new services asked by business users at a lower cost with a good time to market. And all this based on standards that corporate and Web developers like : REST Services using JAX-RS and UI based on OpenSocial gadgets in which you can leverage all the cool and powerful features of HTML5.
What eXo has launched yesterday is a big step for developers since you can now develop, test and deploy your gadgets and services online, and this in your "personal environment" using eXo Cloud IDE supports multi-tenancy. I won't go in all the features of the IDE since you can test it yourself by joining the beta program and look at this video:
eXo Cloud IDE resources:
Posted by
Tug Grall
at
12:55 AM
0
comments
Labels:
Cloud,
exo,
open social
In this article you will learn how to create a REST service using JAX-RS reference implementation (Jersey) and deploy it on Google AppEngine.
in the toolbar . It is
also possible to do it
using the menu File >
Web Application Project
in the Eclipse console.<servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.grallandco.employee.service.rest.impl</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/resources/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping>
package com.grallandco.employee.service.rest.impl;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
@Path("/hr/")
public class EmployeeResource {
@GET
@Produces("text/plain")
@Path("/employee")
public String getEmployee() {
return "Hello World!";
}
}
You should be able to test it, stop the server and run it again, enter the
following URL in your browser:
available in the Eclipse toolbar.
<?xml version="1.0" encoding="utf-8"?> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <application>[your-application-id]</application> <version>1</version> <!-- Configure java.util.logging --> <system-properties> <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> </system-properties> </appengine-web-app>
package com.grallandco.employee.service.model;
import java.util.Date;
public class Employee {
private String firstName;
private String lastName;
private Date hireDate;
private String email;
public Employee(String firstName, String lastName, Date hireDate, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.hireDate = hireDate;
this.email = email;
}
public Employee() {}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Date getHireDate() {
return hireDate;
}
public void setHireDate(Date hireDate) {
this.hireDate = hireDate;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("First: ").append(getFirstName());
sb.append(" - Last: ").append(getLastName());
sb.append(" - Date: ").append(getHireDate());
sb.append(" - Email: ").append(getEmail());
return sb.toString();
}
}
When implementing your "real" application with some persistence layer
this POJO is the one as JDO/JPA entity.package com.grallandco.employee.service.converter;
import java.util.Date;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.grallandco.employee.service.model.Employee;
@XmlRootElement(name = "employee")
public class EmployeeConverter {
private Employee entity = null;
public EmployeeConverter() {
entity = new Employee();
}
public EmployeeConverter(Employee entity) {
this.entity = entity;
}
@XmlElement
public String getFirstName() {
return entity.getFirstName();
}
@XmlElement
public String getLastName() {
return entity.getLastName();
}
@XmlElement
public Date getHireDate() {
return entity.getHireDate();
}
@XmlElement
public String getEmail() {
return entity.getEmail();
}
public Employee getEmployee() {
return entity;
}
public void setFirstName(String firstName) {
entity.setFirstName(firstName);
}
public void setHireDate(Date hireDate) {
entity.setHireDate(hireDate);
}
public void setLastName(String email) {
entity.setEmail(email);
}
public void setEmail(String lastName) {
entity.setLastName(lastName);
}
}
You can now update your service to use this utility/converter class to
return XML or JSON ojbect based on the content type of the request.package com.grallandco.employee.service.rest.impl;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import com.grallandco.employee.service.converter.EmployeeConverter;
import com.grallandco.employee.service.model.Employee;
@Path("/hr/")
public class EmployeeRessource {
@GET
@Produces({"application/xml", "application/json"})
@Path("/employee/{employeeEmail}/")
public EmployeeConverter getEmployee( @PathParam ("employeeEmail") String email) {
//dummy code
Employee emp = new Employee();
emp.setEmail(email);
emp.setFirstName("John");
emp.setLastName("Doe");
EmployeeConverter converter = new EmployeeConverter(emp);
return converter;
}
}
tgrall$ curl -H "Accept: application/json" http://localhost:8080/resources/hr/employee/tug@grallandco.com
{"email":"tug@grallandco.com","firstName":"John","lastName":"Doe"}
Posted by
Tug Grall
at
5:33 AM
32
comments
Labels:
Cloud,
google,
Rest,
Web Services