Thursday, February 22, 2018

@Entity vs @Table for hibernate

@Entity(name = "foo") => this name will be used to name Entity
@Table(name = "bar")  => this name will be used to name a table in DB

Sunday, February 18, 2018

How to install memcached in windows? Or [Memcached on Windows Failed to ignore SIGHUP: No error failed to daemon() in order to daemonize]

Memcached Download


Version: memcached-win64-1.4.4-14.zip

Then I followed 3 tutorials:

1. First follow this tutorial: https://imak47.wordpress.com/tag/failed-to-ignore-sighup/
2. Run the command below:
sc create "Memcached11211" binPath= "C:\memcached\memcached.exe -d runservice -p 11211" DisplayName= "Memcached11211" start= auto

3. Then we start them:
C:\memcached>sc start Memcached11211

SERVICE_NAME: Memcached11211
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 5412
        FLAGS              :

C:\memcached>sc start Memcached11212

SERVICE_NAME: Memcached11212
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 7976
        FLAGS              :

C:\memcached>netstat -an | grep 112
File STDIN:
  TCP    0.0.0.0:11211          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:11212          0.0.0.0:0              LISTENING
  TCP    [::]:11211             [::]:0                 LISTENING
  TCP    [::]:11212             [::]:0                 LISTENING
  UDP    0.0.0.0:11211          *:*
  UDP    0.0.0.0:11211          *:*
  UDP    [::]:11211             *:*
  UDP    [::]:11211             *:*�
Note however that as configured, the udp port is still 11211, so it would need to be changed to ensure that udp can be used as well for both services.
You would add a -u 11211 and -u 11212 to the sc configuration lines.
To stop and individual memcached service you would use:
sc stop memcached11211
sc stop memcached11212
to remove the services do:
sc delete memcached11211
sc delete memcached11212
If however you're just trying it out on different ports then just use multiple cmd windows and run it that way.
Resource Link: 

Tuesday, February 6, 2018

Java Concurrency: Understanding Thread Pool and Executors

IntelliJ Necessary Shortcuts

============================================
ctrl + G --> Go to line
============================================
ctrl + shift + N --> For file searching
ctrl + F --> For Find
ctrl + shift + F --> For Full project search
============================================
ctrl + shift + alt + L --> For formatting
ctrl + tab --> for showing the list of 10 classes. Then press the [tab] again to go another source
ctrl + shift + C --> Path copy
ctrl + D --> Duplicate Line
ctrl + O --> override methods
============================================
ctrl + alt + O --> remove unused methods
ctrl + alt + Y --> refresh project
============================================
ctrl + j --> Then write sout/select --> Press [Enter]
Alt + Enter --> Create unimplemented methods
============================================

Friday, February 2, 2018

Gradle buildscript dependencies vs core dependencies

buildscript dependencies:
buildscript {
    repositories {
        maven { url("https://plugins.gradle.org/m2/") }
    }

    dependencies {
        classpath 'net.saliman:gradle-cobertura-plugin:2.3.2'
        classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release'
    }
}
root level/core dependencies:
repositories{
    mavenLocal()
    maven { url("https://plugins.gradle.org/m2/") }
    maven { url "https://repo.spring.io/snapshot" }
}

dependencies {
        //Groovy
        compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.3.10'

        //Spock Test
        compile group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.3'

        //Test
        testCompile group: 'junit', name: 'junit', version: '4.10'
        testCompile group: 'org.testng', name: 'testng', version: '6.8.5'
}
So, First I want to clarify in single word that
i) buildscript dependencies jar file will be downloaded from buildscript repositories.[Project external dependency]
ii) root level dependencies jar file will be downloaded from root level repositories.[For project dependency]
Here,
The “buildscript” block only controls dependencies for the buildscript process itself, not for the application code. As various gradle plugin like,gradle-cobertura-plugingradle-lint-plugin are found from buildscript repos. Those plugins would not be referenced as dependencies for the application code.
But for project compilation and test running jar files like groovy all jar, junit and testng jar will be found from root level repositories.
And another thing, the maven { url("https://plugins.gradle.org/m2/") }portion can be used in both blocks. Because they are used for different dependencies.