Home Navigation

Tuesday 27 December 2016

Challenges with Microservices


  • Complexity has moved out of the application, but into the operations layer
  • Services may be unavailable: Much more monitoring needed.
  • Remote calls more expensive than in-process calls
  • Transactions: Must rely on eventual consistency over ACID
  • Features span multiple services
  • Change management becomes a different challenge, need to consider the interaction of services, Dependency management / versions
  • Refactoring module boundaries
Fallacies of distributed computing:
  • The network is reliable
  • Latency is zero
  • Bandwidth is infinite
  • The network is secure
  • Topology doesn't change
  • There is one administrator
  • Transport cost is zero
  • The network is homogeneous

Thursday 22 December 2016

Configure Auto Deploy option Websphere 8 application server

- Login to websphere application server admin console, then go to the application->Global deployment settings


- Make sure to check mark the option "Monitor directory to automatically deploy application
- Give a directory path as your wish, or you may keep the default one which is reside in the Installation_root directory.
- Set the polling interval


I have set the below options


- Save and apply the settings and restart your server

make sure the directory you set is exists



Now drop EAR, WAR, JAR file to C:\RSA\monitoredDeployableApps\servers\server1, the application will be installed automatically. Monitor directory to automatically deploy applications.

To uninstall an application file that was previously installed using monitored directory

You can also install, update, or uninstall an application file by dragging or copying an application properties file to a monitored directory. The properties file must specify the deployment actions to be performed.

By default, monitored directory deployment is disabled.

Monitored directory
Specifies the directory to use for monitored directory deployment. The default monitored directory is monitoredDeployableApps. Using this setting, you can specify a different default monitored directory.

For deployment by dragging or copying an enterprise application file to a monitored directory, the directory to which you add enterprise application files depends upon the product profile:

•For base (stand-alone) application servers, the default monitored directory is the monitoredDeployableApps/servers/server_name directory of the application server profile.

•For deployment managers, the default monitored directories are the monitoredDeployableApps/servers/server_name, monitoredDeployableApps/nodes/node_name/servers/server_name, and monitoredDeployableApps/clusters/cluster_name directories of the deployment manager profile.

For deployment using properties files, the monitored directory is a subdirectory named deploymentProperties of the directory specified by this setting; for example, monitoredDeployableApps/deploymentProperties.

To change the default monitored directory, specify a different directory path for this setting. List the entire value for the directory, including the environment variable. Monitor directory to automatically deploy applications must be enabled to change this setting.

REF: http://www.webspheretools.com/sites/webspheretools.nsf/docs/WebSphere%208%20Auto%20Deploy

Wednesday 21 December 2016

application.xml file is not created when created EAR project in RSA

This might happen when you create EAR project and don't check the option to generate application.xml file.

If the application.xml file is missing, you can try by this way

Project -> Right click -> Java EE -> Open Application Server Deployment Descriptor Or

Project -> Right click -> Java EE -> Generate Deployment Descriptor

Could not find a valid parent module to add to the server when try to run a web application in webshpere RSA

Problem: When try to run a webapplication using RSA, right click project -> Run as -> Server, then it shows an error message that Could not find a valid parent module to add to the server

Solutions: There are two possible solutions
Option - 1:
                 Create the project project from the scratch and make sure to select the option "Add project to an                  EAR" in create dynamic webproject window

Option - 2:
                Create an EAR project and then add the web application project as a web module in EAR                     project

Monday 19 December 2016

Microservices basics

There is no formal definition of microservices but we can summarize in short, the mircoservice architectural style is an approach to developing a single application as a suite of small services, each running its own process and communicating with lightweight mechanisms ( http resource api, REST, messaging queue) . So it introduces distributed computing and synchronization communication.

These services are built around business capabilities and dependently deploy-able by fully automated machinery.

We can attempt to describe microservices with its some characteristics

Monolothic vs Microservices


Componentization via services: Component is something independently replaceable and independently upgrade-able.
When we talk about component we think of two types of software component one is Library as component that are linked into a program and called using in-memory function calls, while service runs on his own process who communicate with a mechanism such as a web service. In microservices we consider component as service not library.

Organize around business capabilities: 

The microservice approach to division is different, splitting up into services organized around business capability. Such services take a broad-stack implementation of software for that business area, including user-interface, persistant storage, and any external collaborations. Consequently the teams are cross-functional, including the full range of skills required for the development: user-experience, database, and project management.

Products not projects:

Smart endpoints and dumb pipes: When building communication structures between different processes, we've seen many products and approaches that stress putting significant smarts into the communication mechanism itself. A good example of this is the Enterprise Service Bus (ESB), where ESB products often include sophisticated facilities for message routing, choreography, transformation, and applying business rules.

The microservice community favours an alternative approach: smart endpoints and dumb pipes. Applications built from microservices aim to be as decoupled and as cohesive as possible - they own their own domain logic and act more as filters in the classical Unix sense - receiving a request, applying logic as appropriate and producing a response. These are choreographed using simple RESTish protocols rather than complex protocols such as WS-Choreography or BPEL or orchestration by a central tool.

The two protocols used most commonly are HTTP request-response with resource API's and lightweight messaging

Decentralized Governance: It made the system loosely coupled.

Decentralized Data Management: Every mirco service is resposible for its own data model and data.


Infrastructure Automation: Infrastructure automation techniques have evolved enormously over the last few years - the evolution of the cloud and AWS in particular has reduced the operational complexity of building, deploying and operating microservices.

Many of the products or systems being build with microservices are being built by teams with extensive experience of Continuous Delivery and it's precursor, Continuous Integration. Teams building software this way make extensive use of infrastructure automation techniques.

You also need to have a good monitoring system to monitor all the services

Design for failure: This is one of the most important characteristics. Your architecture should handle if any of the service goes offline. You have to have an alternative way of routing the failure service.

Evolutionary Design: Microservice practitioners, usually have come from an evolutionary design background and see service decomposition as a further tool to enable application developers to control changes in their application without slowing down change. Change control doesn't necessarily mean change reduction - with the right attitudes and tools you can make frequent, fast, and well-controlled changes to software.

Whenever you try to break a software system into components, you're faced with the decision of how to divide up the pieces - what are the principles on which we decide to slice up our application? The key property of a component is the notion of independent replacement and upgradeability - which implies we look for points where we can imagine rewriting a component without affecting its collaborators. Indeed many microservice groups take this further by explicitly expecting many services to be scrapped rather than evolved in the longer term.

Key to microservices are
- Divide component by business capabilities
- Each microservice should have his own datastore
- Stateless communication
- A good team, ideal two pizza method

Ref: Martin fowler

org.eclipse.jgit.api.errors.TransportException, This exception shows when push/pull to git remote repo from eclipse

Problem:


Solutions:

Window->Preference->Team->Git->Add Entry button

And put the following: key=http.sslVerify, value=false


Try the git command push/pull, it should be working now.

Sunday 27 November 2016

Life cycle of a Thread (Thread States)

There are 4 states in thread life cycle in java new, runnable, non-runnable and terminated. There is no running state.

New: The thread is in new state if you create an instance of Thread class but before the invocation of start() method.

Runnable: The thread is in runnable state after invocation of start() method, but the thread scheduler has not selected it to be the running thread.

Running: The thread is in running state if the thread scheduler has selected it.

Non-Runnable (Blocked) : This is the state when the thread is still alive, but is currently not eligible to run.

Terminated: A thread is in terminated or dead state when its run() method exits.

Wednesday 16 November 2016

DB Connection issue, StaleConnectionException: null DSRA0010E: SQL State = 56038, Error Code = -4,743

StackTrace:

aused by: com.ibm.websphere.ce.cm.StaleConnectionException: null DSRA0010E: SQL State = 56038, Error Code = -4,743
       at com.ibm.ws.rsadapter.spi.ServerFunction.handleStaleStatement(ServerFunction.java:695)
       at com.ibm.ws.rsadapter.AdapterUtil.mapException(AdapterUtil.java:2279)
       at com.ibm.ws.rsadapter.AdapterUtil.translateSQLException(AdapterUtil.java:1584)
       at com.ibm.ws.rsadapter.spi.WSRdbDataSource.getConnection(WSRdbDataSource.java:2374)
       at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.getConnection(WSManagedConnectionFactoryImpl.java:1782)
       at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1551)
       at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1107)
       at com.ibm.ejs.j2c.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:2160)
       at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1838)
       at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3809)
       at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3085)
       at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548)
       at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031)
       at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:644)
       at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:611)
       at com.workbrain.tool.jdbc.safe.SafeDataSource.getConnection(SafeDataSource.java:52)
       at com.workbrain2.platform.tool.jdbc.proxy.ProxyDataSource.getConnection(ProxyDataSource.java:96)
       at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
       at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
       ... 138 more
---- Begin backtrace for Nested Throwables
java.sql.SQLException: null DSRA0010E: SQL State = 56038, Error Code = -4,743
       at com.ibm.db2.jcc.am.gd.a(gd.java:752)
       at com.ibm.db2.jcc.am.gd.a(gd.java:66)
       at com.ibm.db2.jcc.am.gd.a(gd.java:135)
       at com.ibm.db2.jcc.am.so.c(so.java:2763)
       at com.ibm.db2.jcc.am.so.d(so.java:2751)
       at com.ibm.db2.jcc.am.so.a(so.java:2200)
       at com.ibm.db2.jcc.am.so.a(so.java:2176)
       at com.ibm.db2.jcc.t4.ab.h(ab.java:136)
       at com.ibm.db2.jcc.t4.ab.b(ab.java:41)
       at com.ibm.db2.jcc.t4.o.a(o.java:32)
       at com.ibm.db2.jcc.t4.tb.i(tb.java:145)
       at com.ibm.db2.jcc.am.so.ib(so.java:2169)
       at com.ibm.db2.jcc.am.so.a(so.java:3248)
       at com.ibm.db2.jcc.am.so.a(so.java:691)
       at com.ibm.db2.jcc.am.Connection.getJccSpecialRegisterProperties(Connection.java:8123)
       at com.ibm.db2.jcc.am.hf.getJccSpecialRegisterProperties(hf.java:1044)
       at com.ibm.ws.rsadapter.dbutils.impl.DB2UniversalUtilityImpl.getJccSpecialRegisterProperties(DB2UniversalUtilityImpl.java:386)
       at com.ibm.ws.rsadapter.spi.InternalDB2UniversalDataStoreHelper.addDefaultHPExtendedProperties(InternalDB2UniversalDataStoreHelper.java:2046)
       at com.ibm.ws.rsadapter.spi.WSRdbDataSource.getConnection(WSRdbDataSource.java:2322)
       at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.getConnection(WSManagedConnectionFactoryImpl.java:1782)
       at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1551)
       at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1107)
       at com.ibm.ejs.j2c.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:2160)
       at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1838)
       at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3809)
       at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3085)
       at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548)
       at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031)
       at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:644)
       at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:611)
       at com.workbrain.tool.jdbc.safe.SafeDataSource.getConnection(SafeDataSource.java:52)
       at com.workbrain2.platform.tool.jdbc.proxy.ProxyDataSource.getConnection(ProxyDataSource.java:96)
       at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
       at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
       at com.workbrain2.platform.util.WbDataSourceUtil.getConnection(WbDataSourceUtil.java:74)
       at com.workbrain2.platform.svc.DbServer.impl.DbServerImpl.init(DbServerImpl.java:63)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
       at java.lang.reflect.Method.invoke(Method.java:620)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1702)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
       at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
       at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
       at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
       at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
       at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
       at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
       at com.workbrain2.platform.core.context.WbClassPathXmlApplicationContext.<init>(WbClassPathXmlApplicationContext.java:39)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:86)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:58)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:542)
       at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)

Solutions: Change the value for the property validateNewConnection to : true. Stop and restart the server.

Thursday 10 November 2016

Switch statement, copy in clipboard and interactive mode in windows command batch script

Interactive area to create a choice:

SETLOCAL ENABLEEXTENSIONS
SET /P M=Type 1, 2, 3, or 4 then press ENTER:



Switch statement Area:

2>NUL CALL :CASE_%M%

:CASE_1
    Do your stuff
:CASE_2
    Do your stuff
:CASE_3
    Do your stuff
:DEFAULT_CASE
    Do your stuff
:EOF

Copy Clip board:

SET "PASS=HELLO"
echo | SET /p=%PASS%|CLIP.EXE

Wednesday 9 November 2016

Graph representations

Graph is one of the most important data structure in computer science. There are several ways to represent graphs, each with its advantages and disadvantages. Some situations, or algorithms that we want to run with graphs as input, call for one representation, and others call for a different representation. Here, we'll see three ways to represent graphs.

Edge lists: One simple way to represent a graph is just a list, or array, of |E|∣E∣ edges, which we call an edge list. Since each edge contains just two or three numbers, the total space for an edge list is Theta Θ(E). For example, here's how we represent an edge list in JavaScript for the social network graph:

[ [0,1], [0,6], [0,8], [1,4], [1,6], [1,9], [2,4], [2,6], [3,4], [3,5],[3,8], [4,5], [4,9], [7,8], [7,9] ]

Edge lists are simple, but if we want to find whether the graph contains a particular edge, we have to search through the edge list. If the edges appear in the edge list in no particular order, that's a linear search through |∣E∣ edges.

Adjacency matrices: For a graph with |V| vertices, an adjacency matrix is a |V| times ∣V∣×∣V∣ matrix of 0s and 1s, where the entry in row i and column j is 1 if and only if the edge (i,j)(i,j) is in the graph.

[ [0, 1, 0, 0, 0, 0, 1, 0, 1, 0],
  [1, 0, 0, 0, 1, 0, 1, 0, 0, 1],
  [0, 0, 0, 0, 1, 0, 1, 0, 0, 0],
  [0, 0, 0, 0, 1, 1, 0, 0, 1, 0],
  [0, 1, 1, 1, 0, 1, 0, 0, 0, 1],
  [0, 0, 0, 1, 1, 0, 0, 0, 0, 0],
  [1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
  [1, 0, 0, 1, 0, 0, 0, 1, 0, 0],
  [0, 1, 0, 0, 1, 0, 0, 1, 0, 0] ]

Advantages
  • we can find out whether an edge is present in constant time

Disadvantages:
  •  First, it takes Theta(V^2) space. In other words, for a sparse graph, the adjacency matrix is mostly 0s, and we use lots of space to represent only a few edges
  • Second, if you want to find out which vertices are adjacent to a given vertex ii, you have to look at all ∣V∣ entries in row ii, even if only a small number of vertices are adjacent to vertex ii.

For an undirected graph, the adjacency matrix is symmetric: the row ii, column jj entry is 1 if and only if the row jj, column ii entry is 1. For a directed graph, the adjacency matrix need not be symmetric.

Adjacency lists: An array of linked lists is used. Size of the array is equal to number of vertices. Let the array be array[]. An entry array[i] represents the linked list of vertices adjacent to the ith vertex. This representation can also be used to represent a weighted graph. The weights of edges can be stored in nodes of linked lists
Vertex numbers in an adjacency list are not required to appear in any particular order, though it is often convenient to list them in increasing order, as in this example.

[ [1, 6, 8],
  [0, 4, 6, 9],
  [4, 6],
  [4, 5, 8],
  [1, 2, 3, 5, 9],
  [3, 4],
  [0, 1, 2],
  [8, 9],
  [0, 3, 7],
  [1, 4, 7] ]

We can get to each vertex's adjacency list in constant time, because we just have to index into an array. To find out whether an edge (i,j) is present in the graph, we go to i's adjacency list in constant time and then look for j in i's adjacency list. How long does that take in the worst case? The answer is Θ(d), where dd is the degree of vertex i, because that's how long i's adjacency list is.

for (var j = 0; j < graph[i].length; j++) {
    doStuff(graph[i][j]);
}

Wednesday 26 October 2016

Asymptotic notation

The running time of an algorithm uses a combination of two ideas.
  • First, we need to determine how long the algorithm takes, in terms of the size of its input. 
  • The second idea is that we must focus on how fast a function grows with the input size. We call this the rate of growth of the running time. 

Here's a chart showing values of 6n^2 and 100n + 300 for values of n from 0 to 100:

We'll see three forms of asymptotic notation: big-Theta Θ notation, big-O notation and big-Omega Ώ notation.

Big-Θ (Big-Theta) notation: When we say that a particular running time is Θ(n), we're saying that once n gets large enough, the running time is at least k1.n and at most k2.n for some constants k1 and k2. Here's how to think of Θ(n):

When we use big-Θ notation, we're saying that we have an asymptotically tight bound on the running time. "Asymptotically" because it matters for only large values of n. "Tight bound" because consider the running time to within a constant factor above and below.

Here's a list of functions in asymptotic notation that we often encounter, listed from fastest to slowest in performance.
  • Θ(1) 
  • Θ(lgn) 
  • Θ(n) 
  • Θ(nlgn) 
  • Θ(n^2) 
  • Θ(n^2lgn) 
  • Θ(n^3) 
  • Θ(2^n)
Note that an exponential function a^n, where a>1, grows faster than any polynomial function n^b, where b is any constant.

Big-O notation: We use big-Θ notation to asymptotically bound the growth of a running time to within constant factors above and below. Sometimes we want to bound from only above. For example, although the worst-case running time of binary search is Θ(lgn), it would be incorrect to say that binary search runs in Θ(lgn) time in all cases. What if we find the target value upon the first guess? Then it runs in Θ(1) time. The running time of binary search is never worse than Θ(lgn), but it's sometimes better. It would be convenient to have a form of asymptotic notation that means "the running time grows at most this much, but it could grow more slowly." We use "big-O" notation for just such occasions.

We say that the running time is "big-O of f(n)" or just "O of f(n)." We use big-O notation for asymptotic upper bounds, since it bounds the growth of the running time from above for large enough input sizes.



Now we have a way to characterize the running time of binary search in all cases. We can say that the running time of binary search is always O(lgn). We can make a stronger statement about the worst-case running time: it's Θ(lgn). But for a blanket statement that covers all cases, the strongest statement we can make is that binary search runs in O(lgn) time.

Big-Ω(Big-Omega) notation:  Sometimes, we want to say that an algorithm takes at least a certain amount of time, without providing an upper bound. We use big-Ω notation; that's the Greek letter "omega."

If a running time is Ω(f(n)), then for large enough nn, the running time is at least k.f(n) for some constant k. Here's how to think of a running time that is Ω(f(n)):

We say that the running time is "big-Ωf(n)." We use big-Ω notation for asymptotic lower bounds, since it bounds the growth of the running time from below for large enough input sizes.

:Common Data Structure Operations:

Data Structure Time Complexity Space Complexity
Average Worst Worst
Access Search Insertion Deletion Access Search Insertion Deletion
Array Θ(1) Θ(n) Θ(n) Θ(n) O(1) O(n) O(n) O(n) O(n)
Stack Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)
Queue Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)
Singly-Linked List Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)
Doubly-Linked List Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)
Skip List Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n log(n))
Hash Table N/A Θ(1) Θ(1) Θ(1) N/A O(n) O(n) O(n) O(n)
Binary Search Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n)
Cartesian Tree N/A Θ(log(n)) Θ(log(n)) Θ(log(n)) N/A O(n) O(n) O(n) O(n)
B-Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)
Red-Black Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)
Splay Tree N/A Θ(log(n)) Θ(log(n)) Θ(log(n)) N/A O(log(n)) O(log(n)) O(log(n)) O(n)
AVL Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)
KD Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n)

Array Sorting Algorithms 
Algorithm Time Complexity Space Complexity
Best Average Worst Worst
Quicksort Ω(n log(n)) Θ(n log(n)) O(n^2) O(log(n))
Mergesort Ω(n log(n)) Θ(n log(n)) O(n log(n)) O(n)
Timsort Ω(n) Θ(n log(n)) O(n log(n)) O(n)
Heapsort Ω(n log(n)) Θ(n log(n)) O(n log(n)) O(1)
Bubble Sort Ω(n) Θ(n^2) O(n^2) O(1)
Insertion Sort Ω(n) Θ(n^2) O(n^2) O(1)
Selection Sort Ω(n^2) Θ(n^2) O(n^2) O(1)
Tree Sort Ω(n log(n)) Θ(n log(n)) O(n^2) O(n)
Shell Sort Ω(n log(n)) Θ(n(log(n))^2) O(n(log(n))^2) O(1)
Bucket Sort Ω(n+k) Θ(n+k) O(n^2) O(n)
Radix Sort Ω(nk) Θ(nk) O(nk) O(n+k)
Counting Sort Ω(n+k) Θ(n+k) O(n+k) O(k)
Cubesort Ω(n) Θ(n log(n)) O(n log(n)) O(n)

Ref: Khan Academy

Wednesday 12 October 2016

Some important file location for WebSphere Application Server

Published Application EAR File:

{WEBSHPERE_INSTALLED_LOCATION}\profiles\{PROFILE_NAME eg AppSrv1}\installedApps\{CELL_NAME eg WVWNO006C0634Node01Cell}\{YOUR_APP_NAME}

Log file Location:

{WEBSHPERE_INSTALLED_LOCATION}\profiles\{PROFILE_NAME eg AppSrv1}\logs\server1

Tuesday 11 October 2016

How to configure custom datasource properties using websphere application server console like currentSQLID

Open WebSphere application server console, from server tab right click on the server and choose Administration->Run Administrative console

Then on the left hand side menu go to resources section and pick Data Sources

Click on the datasource you need to add/change properties

Then follow the below path

{DATA_SOURCE} -> custom properties 

Now you can pick the properties you want to change/add.

PSCP Command to transfer file from/to Unix server

PSCP is a freeware SCP (Secure CoPy) program for the Windows command line processor. You can use this program instead of FTP for copying files to or from the Unix servers at the NBER offices. FTP is not allowed from clients outside nber.org to servers inside the firewall because FTP leaves passwords in plain-text and vulnerable to eavesdropping. PSCP should work with any host supporting SSH, not just at NBER.

pscp username@yourhost:file.foo c:\temp\file.foo


pscp -v c:\"my documents"\file.foo username@nber.org:file.foo

Thursday 6 October 2016

Some useful ant commands

Delete files inside a zip/jar/war/ear:

<project name="myproject">
<target name="updateZip">
<zip destfile="updatedZip.zip">
<zipfileset src="baseZipFromWhereToDelete.zip" excludes="path1,path2" />
</zip>
</target>
</project>

Inject/update some content inside zip/jar/war/ear:

<project name="myproject">
<target name="updateZip">
<zip update="true" destfile="theFileNeedsToBeUpdated.zip" baseDir="TheContentWhichWillBeIjected" />
</target>
</project>

How to compress/zip a set of files:

<zip destfile="TheZipFileNameWhichWillBeCreated.zip" basedir="TheContentWhichAreGoingToBeCompressed" />

Setting up data source in TomEE at EAR level

Prerequisite:
  1. Configure TomEE to deploy EAR Application in Apps directory
    • Got to the directory {TOMEE_HOME}\conf\
    • Open the file tome.xml in a text editor
    • <Deployments dir="apps" /> add this tag to tome.xml
    • And Create a directory apps in {TOMEE_HOME}
  2. Configure data source at EAR level
      • Add the data-source information according to the database you have chosen. And make sure you add the schema as well. You can copy the below schema to your application.xml file

xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
version="6"

      • To get the database class name please follow the below link http://tomee.apache.org/common-datasource-configurations.html
      • Now open in a text editor web.xml file from WEB-INF directory of webmodule project and declare the resource reference you created in application.xml file in EAR module. Make sure the reference name is the same as data-source name in application.xml file.  
      • You can now call the datasource from your code. Below is an example of calling datasource from a jsp page.    
      • Build the application and copy the .ear file to {TOMEE_HOME}\apps directory.
      • Test the application web application from web browser.