Monday, 20 March 2017
GitLab Code Chekout,Checkin and Merge Request
This summary is not available. Please
click here to view the post.
How to Check if MySQL Instance is read only
In order to find out if your DB server in read mode or read/write mode.
Follow the below Steps:
- Login into your DB Server using MySQL Tools,Mysqlem etc.
- Run below queries:
- SELECT @@global.read_only;
- If the Output is 1, it means DB server is read only.
- else if Output is 0, it means DB server is both read/write.
Enjoy Reading.
Wednesday, 15 March 2017
Enable Access logs in Wildfly 8.1
In order to enable access logs in Wildfly 8.1,Please refer below steps:
- Go to WILDFLY_HOME/standalone/configuration folder.
- Open Standalone.xml and put following snippet under <subsystem xmlns="urn:jboss:domain:undertow:1.2">
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" record-request-start-time="true"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<access-log pattern="%h	%p	%l	%u	%t	"%r"	%s	%b	"%{i,Referer}"	"%{i,User-Agent}"&#x
9;%D	"%{i,X-Forwarded-For}"	"%{i,True-Client-IP}"	"%{i,JSESSIONID}c"" directory="${jboss.server.log.dir}" prefix="access-log"
worker="default" rotate="true"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
Enable Access logs in JBOSS 7.2.1
In order to enable access logs in JBOSS 7.2.1,Please refer below steps:
- Go to JBOSS_HOME/standalone/configuration folder.
- Open Standalone.xml and put following snippet under <subsystem xmlns="urn:jboss:domain:web:1.4">
<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" instance-id="${jboss.instance-id.jvmRoute}" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" max-connections="250"/>
<connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp" max-connections="250"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl name="https" password="g04theau" certificate-key-file="/opt/jboss/certs/wildcard.prod.ch3.s.com.jks"/>
</connector>
<virtual-server name="default-host" enable-welcome-root="false">
<alias name="localhost"/>
<alias name="example.com"/>
<access-log pattern='%h	%p	%l	%u	%t	"%r"	%s	%b	"%{Referer}i"	"%{User-Agent}i"	%D	"%{X-Forwarded-For}i"	"%{True-Clien
t-IP}i"	"%{JSESSIONID}c"' prefix="access-log-" rotate="true">
<directory path="." relative-to="jboss.server.log.dir"/>
</access-log>
</virtual-server>
</subsystem>
For access log pattern configuration, refer Access log Patterns
Enjoy Learning.
Tuesday, 14 March 2017
Tunneling with Local Port Forwarding
This diagram illustrates that our localhost
is being blocked from connection to the Target Server(say Sharp Server) using a
proxy filter in our corporate network.
We need a gateway server which would accept
the requests from the localhost and
fetch data and tunneling it back. Actually the gateway server should have a
access to the Target server to perform the tunneling.
For example, the some.server.com(say pvvault301p.dev.ch3.com) server has already got the access, to connect to the Target
server, so it can act as a gateway to connect to the Target sever from the
localhost .
To Create the SSH
tunnel execute the following from Localhost.
1. First load the
gateway server , which have the access to the Target server, in the putty
2. Select the Tunnels option from the
category to add the binding port (this can be some arbitrary value) of
localhost and remote host ip and port (sharp server ip and active ports).
The ‘L’ switch indicates that a local port forward is need to be
created. The switch syntax is as follows.
|
-L
<local-port-to-listen>:<remote-host>:<remote-port>
Refer the below diagram for understanding
|
Now the SSH client at localhost
will connect to SSH server running at some.server.com
(usually running at port 22) binding port 4444 of localhost to listen for local requests thus creating a SSH tunnel
between some.server.com and localhost. At the some.server.com end it will create a connection to Target Server at port 17030. So localhost doesn’t need to know how to connect to Target Server. Only some.server.com needs to worry about
that. The channel between localhost
and some.server.com will be
encrypted while the connection between some.server.com
and localhost will be unencrypted.
Now it is possible to connect to target server by localhost:4444 at localhost computer.
The some.server.com computer will act as a gateway which would accept requests
from localhost machine and fetch data and tunneling it back.
3. Then click Open and enter the login credentials and keep it open.
Now the server is open to connect to Target
server for the localhost
To test this replace the hardcoded target
server details from the code with the binding port (4444)
The same can be modified in the xml or properties file( for ex:sharpserverconfig.xml) if the server details are taking from it.
After this the connection can be make from
localhost to Target Server through tunneling.
Enjoy Learning.
Rotate an array to the right by a given number of steps
Given an list of integers of Strings.We need to rotate the list in right direction.
There are few approaches to accomplish the Solution:
- We can use two for loops and rotate the elements one by one.
- We can use Collections utility class rotate method.
Sample Program:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
*
*/
/**
* @author Dixit
*
*/
public class RotateElement {
/**
* @param args
*/
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
list.add("1");
list.add("2");
list.add("3");
list.add("4");
list.add("5");
list.add("6");
System.out.println("Before Rotating :" + list);
Collections.rotate(list, 2);
System.out.println("After Rotating :" + list);
}
}
Output:
Before Rotating :[1, 2, 3, 4, 5, 6]
After Rotating :[5, 6, 1, 2, 3, 4]
Enjoy Learning.
Find value that occurs in odd number of times in array of elements.
Given an array of Integers.Some Integers occurs even number of times and some odd.We need to find the number which occurs odd number of times.
Sample:-
Input:{1,2,3,2,3,1,2}
Output:2
Sample Program:
import java.util.HashSet;
import java.util.Set;
public class OddElements {
public static void main(String[] args) {
int[] integerArray={1,2,3,2,3,2,3};
printOddElementOccurence(integerArray);
}
private static void printOddElementOccurence(int[] integerArray) {
Set<Integer> unpaired = new HashSet<Integer>();
for (int i = 0; i<integerArray.length; i++){
if (unpaired.contains(integerArray[i])){
unpaired.remove(new Integer(integerArray[i]));
}else{
unpaired.add(integerArray[i]);
}
}
// all printed out values are odd
for (Integer result : unpaired){
System.out.println(result);
}
}
}
Output:
1
2
3
Enjoy Learning.
Subscribe to:
Posts (Atom)






