Wednesday, January 8, 2014

Joomla2.5 troubleshoot


  1. Error : while uploading and installing  Komento in joomla2.5 from Extension manager 

There was an error uploading this file to the server.

Solution : changed max upload file size to 4M in php.ini
navigated C:\xampp\php and opened php.ini and changed the value of upload_max_filesize to 4M and it worked !!

Friday, January 3, 2014

Horizontal and vertical scaling

Horizontal and vertical scaling[edit]

Methods of adding more resources for a particular application fall into two broad categories: horizontal and vertical scaling.[5]
To scale horizontally (or scale out) means to add more nodes to a system, such as adding a new computer to a distributed software application. An example might be scaling out from one Web server system to three. As computer prices have dropped and performance continues to increase, low cost "commodity" systems have been used for high performance computing applications such as seismic analysis and biotechnology workloads that could in the past only be handled by supercomputers. Hundreds of small computers may be configured in a cluster to obtain aggregate computing power that often exceeds that of computers based on a single traditional RISC processor. This model was further fueled by the availability of high performance interconnects such asGigabit Ethernet, InfiniBand and Myrinet. Its growth has also led to demand for software that allows efficient management and maintenance of multiple nodes, as well as hardware such as shared data storage with much higher I/O performance. Size scalability as the maximum number of processors that system can accommodate.[4]

To scale vertically (or scale up) means to add resources to a single node in a system, typically involving the addition of CPUs or memory to a single computer. Such vertical scaling of existing systems also enables them to use virtualization technology more effectively, as it provides more resources for the hosted set of operating system and application modules to share. Taking advantage of such resources can also be called "scaling up", such as expanding the number of Apache daemon processes currently running. Application scalability refers to the improved performance of running applications on a scaled-up version of the system.[4]
There are tradeoffs between the two models. Larger numbers of computers means increased management complexity, as well as a more complex programming model and issues such as throughput and latency between nodes; also, some applications do not lend themselves to a distributed computing model. In the past, the price difference between the two models has favored "scale up" computing for those applications that fit its paradigm, but recent advances in virtualization technology have blurred that advantage, since deploying a new virtual system over a hypervisor(where possible) is almost always less expensive than actually buying and installing a real one.[dubious ] Configuring an existing idle system has always been less expensive than buying, installing, and configuring a new one, regardless of the model.

Integrated database


http://search400.techtarget.com/tip/What-is-an-integrated-database
http://www.wisegeek.com/what-is-an-integrated-database.htm
http://martinfowler.com/bliki/IntegrationDatabase.html

http://www.wisegeek.com/what-is-an-integrated-database.htm  // example of integrated application http://www.lexisnexis.com/en-us/gateway.page


http://computer.howstuffworks.com/data-integration.htm

An integration database is a database which acts as the data store for multiple applications, and thus integrates data across these applications (in contrast to an ApplicationDatabase).
An integration database needs a schema that takes all its client applications into account. The resulting schema is either more general, more complex or both. The database usually is controlled by a separate group to the applications and database changes are more complex because they have to be negotiated between the database group and the various applications.
The benefit of this is that sharing data between applications does not require an extra layer of integration services on the applications. Any changes to data made in a single application are made available to all applications at the time of database commit - thus keeping the applications' data use better synchronized.

Document oriented database

http://www.mongodb.com/document-databases

Document Databases

When relational databases were introduced into the 1970s, data schemas were fairly simple and straightforward, and it made sense to conceive objects as sets of relationships. For example, an article object might be related to a category (an object), a tag (another object), a comment (another object), and so on.
Because relationships between different types of data were specified in the database schema, these relational databases could be queried with a standard Structured Query Language, or SQL. But the environment for data, as well as programming, has changed since the development of the SQL database:
  • The emergence of cloud computing has brought deployment and storage costs down dramatically, but only if data can be spread across multiple servers easily without disruption. In a complex SQL database, this is difficult because many queries require multiple large tables to be joined together to provide a response. Executing distributed joins is a very complex problem in relational databases.
  • The need to store unstructured data, such as social media posts and multimedia, has grown rapidly. SQL databases are extremely efficient at storing structured information, and workarounds or compromises are necessary for storing and querying unstructured data.
  • Agile development methods mean that the database schema needs to change rapidly as demands evolve. SQL databases require their structure to be specified in advance, which means any changes to the information schema require time-consuming ALTER statements to be run on a table.
In response to these changes, new ways of storing data (e.g. NoSQL databases) have emerged that allow data to be grouped together more naturally and logically, and that loosen the restrictions on database schema. One of the most popular ways of storing data is a document data model, where each record and its associated data is thought of as a “document”. In a document database, such as MongoDB, everything related to a database object is encapsulated together. Storing data in this way has the following advantages:
  • Documents are independent units which makes performance better (related data is read contiguously off disk) and makes it easier to distribute data across multiple servers while preserving its locality.
  • Application logic is easier to write. You don’t have to translate between objects in your application and SQL queries, you can just turn the object model directly into a document.
  • Unstructured data can be stored easily, since a document contains whatever keys and values the application logic requires. In addition, costly migrations are avoided since the database does not need to know its information schema in advance.
Document databases generally have very powerful query engines and indexing features that make it easy and fast to execute many different optimized queries. The strength of a document database’s query language is an important differentiator between these databases.

MongoDB is the Leading NoSQL Document Database

MongoDB's document data model makes it easy to build on, since it supports unstructured data natively and doesn't require costly and time-consuming migrations when application requirements change. MongoDB's documents are encoded in a JSON-like format, called BSON, which makes storage easy, is a natural fit for modern object-oriented programming methodologies, and is also lightweight, fast and traversable.
In addition, MongoDB supports rich queries and full indexes, distinguishing it from other document databases that make complex queries difficult or require a separate server layer to enable them. Its other features include automatic sharding, replication, and more. Read our MongoDB overview to learn more about these features.

ACID properties for database

 http://en.wikipedia.org/wiki/Concurrency_control

Atomicity[edit]

Atomicity requires that each transaction is "all or nothing": if one part of the transaction fails, the entire transaction fails, and the database state is left unchanged. An atomic system must guarantee atomicity in each and every situation, including power failures, errors, and crashes. To the outside world, a committed transaction appears (by its effects on the database) to be indivisible ("atomic"), and an aborted transaction does not happen.

Consistency[edit]

The consistency property ensures that any transaction will bring the database from one valid state to another. Any data written to the database must be valid according to all defined rules, including but not limited to constraints, cascades, triggers, and any combination thereof. This does not guarantee correctness of the transaction in all ways the application programmer might have wanted (that is the responsibility of application-level code) but merely that any programming errors do not violate any defined rules.

Isolation[edit]

The isolation property ensures that the concurrent execution of transactions results in a system state that would be obtained if transactions were executed serially, i.e. one after the other. Providing isolation is the main goal of concurrency control. Depending on concurrency control method, the effects of an incomplete transaction might not even be visible to another transaction.[citation needed]

Durability[edit]

Durability means that once a transaction has been committed, it will remain so, even in the event of power loss, crashes, or errors. In a relational database, for instance, once a group of SQL statements execute, the results need to be stored permanently (even if the database crashes immediately thereafter). To defend against power loss, transactions (or their effects) must be recorded in a non-volatile memory.

Wednesday, January 1, 2014

Difference between Hashmap and Hashtable in java

http://javapostsforlearning.blogspot.de/2013/02/difference-between-hashtable-and-hashmap.html

Difference between Hashtable and HashMap in java

One of the common interview question is "What are differences between Hashtable and HashMap".When I started using them,I used any of them irrespective of their differences.Afterwards i found noticeable differences between them which can affect your performance of application. .Before we actually see differences,let me give you brief introduction of both.

HashMap

HashMap implements Map interface which maps key to value.It is not synchronized and is not thread safe.Duplicate keys are not allowed and null keys as well as value are allowed.
  1. HashMap<Interger,String> employeeHashmap=new HashMap<Integer,String>();  
  2. employeeHashmap.put(1,"Arpit");  
  3. employeeHashmap.put(2,null);  // will work fine  

Hashtable

Hashtable implements Map interface which maps key to value.It is synchronized and thread safe.Duplicate keys are not allowed and null key is not allowed.
  1. Hashtable<Interger,String> employeeHashmap=new Hashtable<Integer,String>();  
  2. employeeHashmap.put(1,"Arpit");  
  3. employeeHashmap.put(2,null);  //not allowed and will throw NullPointer exception at run time  

Hashtable vs HashMap:

Parameter
Hashtable
HashMap
ThreadSafe
Yes
No
Synchronized
Yes
No
Performance
Due to theadSafe and Synchronized,it is often slower than HashMap
In single threaded environment, it is much faster than Hashtable.So if you do not work in multi thread environment ,then hashMap is recommended
Null key
Do not allow
Allows null key as well as values
Fail fast
enumeration in hashtable is not fail fast
Iterator in hashMap is fail fast
Extends
It extends Dictionary class which is quite old
It extends AbstractMap class
Alternative
No alternative
You can use ConcurrentHashMap for multi thread environment

Some important points need to be discussed.
  • Synchonized meaning only one thread can modify one table  at one point of time.When any thread perform update operation on hashtable then it acquires lock on it and other threads have to wait for lock to be released.
  • Fail-fast iterator means if one thread is iterating over hashmap and other thread trying to modify hashmap structurally it will throw ConcurrentModification Exception and fail immediately.Structurally modification means inserting or deleting elements that can change structure of map.

Can we synchronize HashMap?

Yes,We can synchonized a HashMap also with the help of Collections.synchonizedMap(hashmap) so HashMap can be synchronized by

Read more at http://javapostsforlearning.blogspot.com/2013/02/difference-between-hashtable-and-hashmap.html#HUZ14KFDSRm3bVBb.99
  1. Map map=Collections.synchonizedMap(hashmap)  

Hashtable examples in java

http://javarevisited.blogspot.de/2012/01/java-hashtable-example-tutorial-code.html

10 Java Hashtable Examples:

Now let’s move on Hashtable examples in Java following is a list of all examples of hashtable operation we will see in this article:

1. How to put object into Hashtable?
2. How to retrieve object from Hashtable in Java?
3. How to reuse Hashtable by using clear()?
4. How to check if Hastable contains a particular value?
5. How to check if Hashtable contains a particular key?
6. How to traverse Hashtable in Java?
7. How to check if Hashtable is empty in Java?
8. How to Copy content of Hashtable into HashMap?
9. How to find size of Hashtable in Java?
10. How to get all values form hashtable in Java?
11. How to get all keys from hashtable in Java?


Here is complete code example of all above hashtable example or exercises:

import java.util.Collection;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Set;

public class HashtableDemo {

public static void main(String args[]) {

// Creating Hashtable for example
Hashtable companies = new Hashtable();


// Java Hashtable example to put object into Hashtable
// put(key, value) is used to insert object into map
companies.put("Google""United States");
companies.put("Nokia""Finland");
companies.put("Sony""Japan");


// Java Hashtable example to get Object from Hashtable
// get(key) method is used to retrieve Objects from Hashtable
companies.get("Google");


// Hashtable containsKey Example
// Use containsKey(Object) method to check if an Object exits as key in
// hashtable
System.out.println("Does hashtable contains Google as key: "
+ companies.containsKey("Google"));


// Hashtable containsValue Example
// just like containsKey(), containsValue returns true if hashtable
// contains specified object as value
System.out.println("Does hashtable contains Japan as value: "
+ companies.containsValue("Japan"));


// Hashtable enumeration Example
// hashtabl.elements() return enumeration of all hashtable values
Enumeration enumeration = companies.elements();

while (enumeration.hasMoreElements()) {
System.out
.println("hashtable values: " + enumeration.nextElement());
}


// How to check if Hashtable is empty in Java
// use isEmpty method of hashtable to check emptiness of hashtable in
// Java
System.out.println("Is companies hashtable empty: "
+ companies.isEmpty());


// How to find size of Hashtable in Java
// use hashtable.size() method to find size of hashtable in Java
System.out.println("Size of hashtable in Java: " + companies.size());


// How to get all values form hashtable in Java
// you can use keySet() method to get a Set of all the keys of hashtable
// in Java
Set hashtableKeys = companies.keySet();


// you can also get enumeration of all keys by using method keys()
Enumeration hashtableKeysEnum = companies.keys();


// How to get all keys from hashtable in Java
// There are two ways to get all values form hashtalbe first by using
// Enumeration and second getting values ad Collection

Enumeration hashtableValuesEnum = companies.elements();


Collection hashtableValues = companies.values();


// Hashtable clear example
// by using clear() we can reuse an existing hashtable, it clears all
// mappings.
companies.clear();
}
}


Output:
Does hashtable contains Google as key: true
Does hashtable contains Japan as value: true
hashtable values: Finland
hashtable values: United States
hashtable values: Japan
Is companies hashtable empty: false
Size of hashtable in Java: 3


Read more: http://javarevisited.blogspot.com/2012/01/java-hashtable-example-tutorial-code.html#ixzz2pAddPasf