Monday, December 5, 2016

10 Intellij Idea Must Know Shortcuts on Ubuntu

  1. Optimizing imports - Ctrl + Alt+ O
  2. Auto Imports - Alt+enter
  3. System.out.println - type sysout, then press tab
  4. Open a file - Ctrl+N
  5. GoTo Function in class - Ctrl + F12
  6. Auto Indent - Ctrl + Alt + I
  7. Basic Code Completion - Ctrl + Space
  8. Comment a line of code - Ctrl + /
    Uncomment a line of code - Ctrl + Shift + /
  9. Duplicate the current line - Ctrl + D
  10. Finally, Find any action by name - Ctrl + A

Monday, October 24, 2016

Mount a Remote system as a drive on OSx using SSH

Recently I ran into a situation where I needed to mount a remote system folder on my OSx for ease of sharing and convenience. You can totally do without this by just using the terminal. However, writing this hoping to help those who need to do this for one or the other reason.

1. Install Fuse and SSHFS

Download FUSE and SSHFS from OSx Fuse site. Follow the instructions to install Fuse, followed by SSHFS.

2. Create a folder on your mac. This will be the mount point of the remote folder.

anjanas:~ $ ls
Applications Library  Public  id_rsa
Desktop  Movies  PycharmProjects test.txt
Documents Music  dev-vm-mount workspace
Downloads Pictures dwhelper
anjanas:~ $ mkdir mount
anjanasblrmbp:~ $ ls
Applications Library  Public  id_rsa
Desktop  Movies  PycharmProjects mount
Documents Music  dev-vm-mount test.txt
Downloads Pictures dwhelper workspace

3. Create a keyless access to your server

Refer this link for the same.

4. Mount the remote system as a folder on OSx

sshfs -o IdentityFile=~/.ssh/id_rsa anjana@remote.ip:/home/anjana/workspace ~/mount

Now you can treat the remote folder as any other folder on your machine.

Unmounting this system can be achieved as follows:
sudo diskutil umount force ~/mount

That's it for this post.
References: Mount a remote system as a drive on Mac OSx

Thursday, March 31, 2016

Accessing Solr Cloud on AWS from SolrJ

We have a Solr cloud installation on AWS EC2 instances. We use the SolrJ Client from our Java application. Till date we used to have a Solr Cloud installation on our local machine in order to test the code against. As the team started growing, we realized that we should have a way to access the AWS Solr Cloud from our local boxes, so that the Solr Cloud setup on local is not a blocker for feature development.

When I started looking around the web for a solution to this issue, I had to mix a few things from a few different documentation pages and this stackoverflow page. Decided to write this blog post to help out others who are running into the same issue. I hope it helps.

So first let's try to understand the reason behind why you get the java.net.UnknownHostException from the SolrJ client.
When the solr cloud is run, each instance registers itself with the zookeeper that is running. This is done with the private IP of the solr machine. So when SolrJ connects to zookeeper, it gets the private IP. And then SolrJ tries to hit the Solr instance with the private IP, leading to an unknown host exception.

In order to get around this you can follow these steps:
Step 1: Run the solr instance with a host name. Zookeeper will use this hostname.
./bin/solr start -cloud -h hostname -p 8985 -z localhost:2181

Step 2: Add the host entry to the /etc/hosts file on your local machine corresponding to the public ip of the solr machine.

And you are done. You can run the java application that uses SolrJ client on your local machine and access the Solr Cloud running on your AWS instance :)