View RSS Feed

All Blog Entries

  1. Configuring Log4J

    by , 02-24-2012 at 08:17 PM
    Log4J is considered to be the most frequently used library, for logging. Log4J present in your application has integration details which will be discussed in this section. A property file and system properties are used to configure Log4J.

    This system property is used for specification of the Log4J configuration file naming. Default configuration file would be, in case it is not specified.

    • log4j.rootCategory=priority
    Commons Lang
  2. Configuring the Underlying Logging System

    by , 02-24-2012 at 08:14 PM
    Java Commons Logging SPI shall be configured for using logging toolkits. A bridge is provided by the Commons Logging to write log messages. Message logging is only supported by it and no API configuration is supported for the logging system.

    Java Commons Logging configuration is dependent upon logging toolkit. Java Commons Logging doesn’t hold responsibility for:

    • Underlying library initialization.
    • Underlying library configuration.
    • Underlying library shutdown.
    Commons Lang
  3. Java Commons Logging Configuration

    by , 02-24-2012 at 08:13 PM
    Java Commons Logging uses these base abstractions.

    • Log- the basic logger
    • LogFactory i.e. How a Log instances is created

    A specific log implemenatation specification is quite useful. LogFactory implementation is specified by the advanced users. These discovery processes are used by the default LogFactory implementations.

    • The org.apache.commons.logging.Log attribute shall be looked for. Java code can be used for setting these attributes. Properties ...
  4. The Logging Component

    by , 02-24-2012 at 08:11 PM
    Logging information is very important while a library is written. Numbers of logging implementations are there in market. A specified logging library usage cant be imposed by a library at the application.

    Logging package is considered to be an ultra thing bridge among various logging implementations. Library using common logging APIs might be used along with some logging implementations, at the run time. Commons logging provides support for different logging implementations. For others, ...
    Commons Lang
  5. Security aspects of server authentication

    by , 02-24-2012 at 08:04 PM
    To do communication with non-trusted web applications or websites, extra care shall be taken while using the default credentials. Activation of the preemptive authentication is done, or for a specific authentication when credentials have not been given explicitly and default credentials would be used by the host HttpClient so that to get authentication with the targeted site.

    To avoid giving the critical & sensitive credentials to some non-trustable website, you shall ...
  6. Preemptive Authentication

    by , 02-24-2012 at 08:03 PM
    Within HttpClient, preemptive authentication can be enabled. HttpClient sends the response of basic authentication before unauthorized is given by server, in preemptive authentication mode. This will be reducing overhead for connection making.
    To enable it, use this code.
    Java Code:
    For preemptive authentication, default credentials are required to be set for proxy host or target. Preemptive authentication will ...
  7. HttpClient Exception handling

    by , 02-24-2012 at 08:01 PM
    Exception types which might be encountered to a HttpClient when HTTP methods are executed, are as following:

    1. protocol exceptions
    2. transport exceptions

    In regular use of the HttpClient, all these exceptions would not propagate to user. Internally handled exceptions by HttpClient have been marked as internal.

    I. Transport exceptions
    II. HTTP transport safety
    III. Protocol exceptions
    IV. Custom exception handler
    V. ...
  8. Apache Server Authentication

    by , 02-24-2012 at 08:00 PM
    Transparent mechanism is present in HttpClient for handling of the authentication. Login credentials are required for the development of application.

    • In HttpState instance, login credentials are being stored.
    • Use the setCredentials method to set these credentials.
    • Use the getCredentials method to retrieve these credentials.

    setDoAuthentication method is present in HttpMethod class. Automatic authorization is provided by it for the HttpClient. Changes ...
  9. Apache Commons HTTPClient

    by , 02-24-2012 at 07:59 PM
    The HTTP i.e. Hyper Text Transfer Protocol is one of the most significant & popular protocol nowadays. HTTP protocol’s role has been expanded by the network growth; web services and other network enable applications. Also, applications which need HTTP protocol are also increasing in number.

    Core functionality is being provided by the package to access resources through HTTP. Full functionality is not provided by this package which is needed by applications. Apache Commons ...
  10. Apache IOUtils

    by , 02-24-2012 at 07:57 PM
    These utility methods are provided by the IOUtils:

    1. Reading
    2. Copying
    3. Writing

    Given methods work at:

    1. InputStream
    2. OutputStream
    3. Writer
    4. Reader

    Bytes would be read a URL by the help of this code and will make them printed.
    Java Code: This is the code to explain IOUtils
    InputStream in = new URL( "" ).openStream();
     try {
       InputStreamReader inR = new InputStreamReader( in
    Commons IO
  11. Apache Commons IO

    by , 02-24-2012 at 07:55 PM
    Commons IO is utilitie’s library to help for development of the IO functionality.
    Main six main areas are:

    • Utility classes – Performance of the common tasks with static methods.
    • Input - Reader implementations & useful input stream.
    • Output - Writer implementations & useful output stream.
    • Filters - File filters implementations.
    • Comparators - java.util.Comparator implementations for files
    • File Monitor - Component to monitor ...
    Commons IO
  12. Apache Commons Collections

    by , 02-24-2012 at 07:54 PM
    Java Commons Collections Framework accelerates the Java applications development, being an empowered data structure. For collection handling, it has now taken a position of standard in Java.
    Java Collections provides implementations, new interfaces & utilities. They are built at JDK classes top. List of features of Java Collections is as following:

    • Bag interface consist of various copies for each object.
    • MapIterator is for iteration, on a Map.
    • Interface BidiMap is
  13. Apache Commons Lang

    by , 02-24-2012 at 07:51 PM
    Core classes manipulation methods are not provided by the Standard Java libraries. Extra methods provided by Apache Commons Lang are:

    For Java, these utilities are provided by the Apache Commons Lang.

    • Lang API
    • Numerical methods
    • String manipulation methods
    • Object reflection
    • Creation and serialization
    • Concurrency
    • System properties
    • Utilities for hashCode
    • Utilities for equals
    • Basic enhancements to java.util.Date
    • Utilities for toString
  14. Apache Commons

    by , 02-24-2012 at 07:48 PM
    Apache commons basic focus is at the Java components which are reusable. It is basically an apache project which consists of three parts.

    • The Commons Proper:

    Reusable Java component repository.
    • The Commons Sandbox :

    Workspace for developing java components.
    • The Commons Dormant :

    Sandbox component repository, which is not active currently.

    Major Principals of the Apache Commons Proper:
    • To create or
    Commons Lang
  15. Benefits of Cassandra

    by , 02-23-2012 at 07:30 PM
    Cassandra database provides a number of benefits. Key benefits of Cassandra database are:

    • Fault Tolerant: It is fault tolerant. Cassandra automatically replicates data to multiple nodes for fault tolerance. Any failed node is replaced immediately with no downtime.
    • Decentralized: It is based on decentralized approach. Every node in Cassandra database cluster is identical. Also there are no network bottlenecks. – Every node in the cluster is identical. There are no network bottlenecks.
  16. NoSQL

    by , 02-23-2012 at 07:28 PM
    It is used to describe a database that does not expose an SQL interface. This term was first introduced in 1998. In 2009, Eric Evans, employee of Rackspace has introduced it again as he wants to organize an event on open source distributed databases.

    NoSQL term is used for such databases, which uses key-value pair architecture. Also it not the case of Cassandra database. These databases do not provide an interface for SQL queries and they avoid join operations normally. Memacached ...
    Tags: nosql Add / Edit Tags
  17. Cassandra Build the index

    by , 02-23-2012 at 07:27 PM
    When the data is ready, next step is to store it into column family. All the tags that are created in tokenizer can be processed in this step. Tokenizer has provided us a list of tags with document IDs. With the help of this information, we can do the following:
    • Check the tags for duplication.
    • Write data to column family in Cassandra.

    Java Code: This is the code to explain index buildning
    private void tokenize(String doc, String docID) {
            //remove all none alpha numeric vals
  18. Cassandra Index generator

    by , 02-23-2012 at 07:23 PM
    In this section, we will create a Cassandra index. The below code explains and simulated a simple indexer. In this index, few components are added. In this code, we read text files as resources for this index generator. After reading content into memory, we pass it to tokenizer. This tokenizer is used to remove all none alpha numeric characters using regular expressions. After this it will separate text files using spaces as delimiter. Finally it chooses randomly words which will be used as tags. ...
  19. Cassandra Delete Operation

    by , 02-23-2012 at 07:21 PM
    In this section, we will discuss that how we can delete a value from Cassandra database using Java code.
    Java Code: This is the code to explain Cassandra Delete Operation
    import org.apache.cassandra.thrift.Deletion;
    long timestamp =System.currentTimeMillis();
    List columns = new ArrayList();
    SlicePredicate slicePredicate = new SlicePredicate();
    Deletion deletion = new Deletion(timestamp);
  20. Cassandra Update Operation

    by , 02-23-2012 at 07:19 PM
    To update data in the Cassandra database, batch_update method is used to perform this action. In the below code, we want to update the email address in the database.
    Java Code: This is the code to explain Cassandra Update Operation
    long timestamp = System.currentTimeMillis();
    Column column = new Column("email".getBytes("utf-8"), "".getBytes("utf-8"), timestamp);
    ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
  21. Cassandra Read Operation

    by , 02-23-2012 at 07:17 PM
    For example we have a number of authors in the database and we want to read them in Java. Below code explains this operation in detail.
    Java Code: This is the code to Cassandra Read Operation
    import org.apache.cassandra.thrift.SlicePredicate;
    import org.apache.cassandra.thrift.SliceRange;
    import org.apache.cassandra.thrift.ColumnOrSuperColumn;
    import org.apache.cassandra.thrift.ColumnParent;
    import org.apache.cassandra.thrift.ConsistencyLevel;
    SlicePredicate slicePredicate = new SlicePredicate();
  22. Cassandra Add Operation

    by , 02-23-2012 at 07:15 PM
    Following code explains add operation in java.
    Java Code: This is the code to explain Cassandra Add Operation
    Map<String, List<ColumnOrSuperColumn>> data = new HashMap<String, List<ColumnOrSuperColumn>>();        
    List<ColumnOrSuperColumn> columns = new ArrayList<ColumnOrSuperColumn>();
    // Create the email column.
    ColumnOrSuperColumn c = new ColumnOrSuperColumn();
    c.setColumn(new Column("email".getBytes("utf-8"), "ronald (at)".getBytes("utf-8"),
  23. Cassandra Search Indexes

    by , 02-23-2012 at 07:10 PM
    We can perform full text search in some application by reading whole content of the document and searching for the required data in document at acceptable speed. This operation is performed every time a query is executed. This approach is not feasible and recommended in cases where a huge amount of data is used for searching. Also almost no one is using this approach to search documents or database.
    With increasing amount of data on the internet, we need to search millions or sometime billions ...
  24. Cassandra Required Libraries

    by , 02-23-2012 at 07:08 PM
    To communicate with the Cassandra database in java, client will need a number of libraries on its classpath. All of these libraries are already provided within “CASSANDRA_HOME/lib” folder of Cassandra installation directory. These libraries include:

    • Apache-cassandra.jar: It contains customization of Thrift communications protocol.
    • slf4j-log4j.jar: It contains plug-in for SLF4J to add support for Log4j.
    • slf4j-api.jar: It’s a wrapper for logging frameworks.
  25. Making Cassandra Database Connection

    by , 02-23-2012 at 07:06 PM
    First thing to do is to create connection to database. For this purpose, on port 9160 open up a connection that would be a default port of Cassandra. Hand over it to the client of Cassandra and he will be taking care to communication to the server:
    Java Code: This is the code to explain Cassandra Database Connection
    import org.apache.thrift.protocol.TBinaryProtocol;
    import org.apache.thrift.protocol.TProtocol;
    import org.apache.thrift.transport.TSocket;
    import org.apache.thrift.transport.TTransport;
    import org.apache.cassandra.thrift.Cassandra;
  26. Cassandra Sorting

    by , 02-23-2012 at 07:04 PM
    Along with ColumnFamily CompareWith attribute, sorting gets specified. Here are few options from which one may select.
    1. BytesType
    2. UTF8Type
    3. LexicalUUIDType
    4. TimeUUIDType
    5. AsciiType
    6. LongType

    Content of Column names are threatened by each of the mentioned type, being a different data type. For example, Column names are being threat by Longtype as 64 Bit long value. Other examples are that suppose of ColumnFamily where CompareWith ...
  27. Cassandra Keyspaces

    by , 02-23-2012 at 07:02 PM
    Keyspaces are very simple. From RDBMS view point, you may make a comparison to your schema. Normally, you just have 1/application. ColumnFamily are present in a key space. However, it shall be noticed that no relationship exists b/w ColumnFamily as they are separate containers. Than, comes the turn of different containers sorting mechanism. This clearly lets you know that in Cassandra, how data model works.
  28. Cassandra SuperColumn Family

    by , 02-23-2012 at 07:00 PM
    Finally, largest container the SuperColumnFamily is here. If ColumnFamily is understandable by you then such construction is not at all harder. Despite of Column, in inner most Map, consider SuperColumns. This will surely make an extra dimension addition.Key of the Map (that consists of SuperColumn) shall be similar as that of name of the SuperColumn.
    Java Code: This is the code to explain Cassandra SuperColumn Family
    public class SuperColumnFamily {
      Byte[] name;
      // The key is a user generated key
  29. Cassandra Column Family

    by , 02-23-2012 at 06:58 PM
    ColumnFamily is considered as a structure which is responsible for keeping infinite rows for people who have RDBMS background. This structure has much resemblance with a Table. You may have an idea that ColumnFamily consists of a name that is compared to Table name. A map with a value(that is a map consisting of Columns) and a key (that is comparable to the identifier of rows). Map and SuperColumn have similar rules and key consists of similar value of name of the Column.

    Java Code: This is the code to explain Cassandra Column Family

    Updated 02-23-2012 at 07:01 PM by Cassandra

  30. Cassandra SuperColumn

    by , 02-23-2012 at 06:56 PM
    A SuperColumn is considered to be a triplet or tuple along with a value and a name. It doesn’t consist of any timestamp, for example the column tuple. It shall be noticed that value is not the binary value, but is more a Map style container. Column or key combinations are present in the map. The most important thing to mention is that name of the column and key consists of same value. Therefore to make it simple, we can say that one or more than one columns are present in SuperColumn.
Page 21 of 48 FirstFirst ... 11192021222331 ... LastLast