SlideShare a Scribd company logo
Side-B: Technical Part
groovyserver
based on: Ver 0.4-SNAPSHOT(7/24)
!"#$%&'()*
based on: Ver 0.4-SNAPSHOT(7/24)
$ groovyserver
GroovyServer   main()
ServerSocket    Listen
               1961
$ groovyclient -e “println(‘Hello, GroovyServ!’)”




      groovyclient




       1961(default)          groovyserver
RequestWorker   start()
ClientConnection#openSession()
                      InvocationRequest
groovyclient   Groovy
Groovy
+,-./012345
67389:3467;5
  <=6#+,4

  based on: Ver 0.4-SNAPSHOT(7/24)
$ groovyserver
GroovyServer   main()
System.in/out/err
!
~/.groovy/groovyserv/cookie
ServerSocket    Listen
               1961
$ groovyclient -e “println(‘Hello, GroovyServ!’)”



      ./groovy/groovyserv/cookie
                              Cookie



   groovyclient

                     Cookie: 425ba835cb32688b1




    1961(default)            groovyserver
Socket   Loopback Address
  RequestWorker
RequestWorker



  ClientConnection




                     CientConnection
                                   ThreadGroup
                       Singleton
RequestWorker   start()
ClientConnection#openSession()
                      InvocationRequest




                           Cookie
groovyclient
        System.in
groovyclient   Groovy
groovyclient
(CWD)            JVM
1.                   “user.dir”
2. JNA         JVM                CWD
3. CWD
GroovyMain
GroovyMain2   Groovy
>?@A4BCDE3:2
-




       (CWD)




    CTRL+C
-




       (CWD)




    CTRL+C
-

       System.out(err)



       System.in



HTTP
System.out(err)
            !script"
println “Hello, GroovyServ!”




                                        Socket
            System.out
                           OutputStream#write()     ClientConnection
         (StreamResponse
          OutputStream)
                                                     OutputStream




 ClientConnectionRepository                        groovyclient
       ThreadGroup
   ClientConnection            if Channel        ==”out”    if Channel   ==”err”
                                    "                         "




                                            Hello, GroovyServ!
groovyclient               StreamRequestHandler
                                      Socket.inputStream.read()


                                     pipedOutputStream.write()

      ClientConnection

     PipedOutputStream                         ClientConnection
                                                  Repository

                                                    ThreadGroup
                                                ClientConnection
        PipedInputStream


                  ClientConnection                System.in
               PipedInputStream          (StreamRequestInputStream)


        System.in

                                                  !script"
                                     System.in.eachLine { ... }
Piped
[    ]                            Size:-1

[   A] StreamRequestInputStream
Socket#getInputStream()

    System.in




[   B] StreamRequestInputStream      PipedInputStream()
Request

   InvocationRequest

                       Groovy

   StreamRequest



Response

   StreamResponse
InvocationRequest
'Cwd:' <cwd> LF
'Arg:' <argn> LF
'Arg:' <arg1> LF
'Arg:' <arg2> LF
'Cp:' <classpath> LF
'Cookie:' <cookie> LF
LF

where:
 <cwd> is current working directory.
 <arg1><arg2>.. are commandline arguments(optional).
 <classpath>.. is the value of environment variable
CLASSPATH(optional).
 <cookie> is authentication value which certify client is
the user who invoked the server.
 LF is line feed (0x0a, 'n').
StreamRequest

'Size:' <size> LF
LF
<data from STDIN>

where:
 <size> is the size of data to send to server. <size>==-1
means client exited.
 <data from STDIN> is byte sequence from standard input.
StreamResponse
'Status:' <status> LF
'Channel:' <id> LF
'Size:' <size> LF
LF
<data for STDERR/STDOUT>

where:
 <status> is exit status of invoked groovy script.
 <id> is 'out' or 'err', where 'out' means standard output
of the program. 'err' means standard error of the program.
 <size> is the size of chunk.
 <data from STDERR/STDOUT> is byte sequence from standard
output/error.
-




       (CWD)




    CTRL+C
Cookie / Loopback only
                         2
 Only from Loopback address


             InetAddress#isLoopbackAddress()
 Cookie
      Loopback address
                                  NG
    HTTP    Cookie
                                               ~/.groovy/groovyserv/
    cookie


    Cookie


          Authentication failed
-




       (CWD)




    CTRL+C
CLASSPATH
       CLASSPATH

InvocationRequest   Cp

GroovyMain2                “groovy.classpath”
          GroovyMain2



        groovy.classpath



                             groovyserver -r

       -cp

InvocationRequest   Arg



      GroovyMain2
-




       (CWD)




    CTRL+C
CWD(Current Working Directory)


       Java

       GroovyServ                                   CWD
                  CWD

$ cd /tmp
$ groovyserver -r
$ cd /home/kobo
$ cat > hoge.txt
HOGE!!
^C
$ groovyclient -e ‘println(new File(“hoge.txt”).text)’
Caught: java.io.FileNotFoundException: hoge.txt (No such file or directory)
   ...SNIP...
“user.dir”

      File#getAbsolutePath()

      “"user.dir", which is initialized during jvm
      startup, should be used as an informative/readonly
      system property” posted 2008-08-18

         http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4117557

JNA            JVM                 CWD

      “user.dir”
      FileInputStream

 CWD

Groovy
JNA   cwd               POM

            <dependency>
              <groupId>net.java.dev.jna</groupId>
              <artifactId>jna</artifactId>
              <version>3.2.2</version>
            </dependency>

                                            #   OK

import com.sun.jna.Library
import com.sun.jna.Native
import com.sun.jna.Platform

interface CLibrary extends Library {
    String libname = (Platform.isWindows() ? "msvcrt" : "c")
    CLibrary INSTANCE = Native.loadLibrary(libname, CLibrary.class)
    int chdir(String dir)
    int _chdir(String dir)
}
-




       (CWD)




    CTRL+C
groovyserver



  Windows        groovyserver.bat

PID             Linux/MacOSX        PID
                     kill

Windows                             Address already in
use

  BAT     PID
-




       (CWD)




    CTRL+C
CTRL+C

groovyclient
        CTRL+C

“Size: -1”

        StreamRequestHandler
-




       (CWD)




    CTRL+C
java.util.concurrent
             2


   StreamRequestHandler
  Groovy
   GroovyInvokeHandler
NW
Groovy




         CTRL+C
System.exit()

                JVM
Maven + GMaven
Maven + GMaven

  GMaven

          Gradle             Gradle

0.4-SNAPSHOT       groovy



  groovyc                     JDK   API   private
                            IncompatibleClassChange
  Error
IntegrationTest
GroovyServ

                          groovyclient



maven-failsafe-plugin                              “mvn integration-
test”

             http://maven.apache.org/plugins/maven-failsafe-plugin/
   index.html

                                     mvn
How to Build
Maven2
  $ cd groovyserv-<Version>
  $ mvn clean verify

              :
  target/groovyserv-<Version>-<OS>-<arch>-bin.zip

Integration-Test
 target/groovyserv-<Version>-<OS>-<arch>.dir/groovyserv-<Version>-<OS>-<arch>

                   :

   EncodeIT                                                   UTF-8
     $ export _JAVA_OPTIONS=-Dfile.encoding=UTF-8


     $ mvn -Dmaven.test.skip=true clean package

Windows                  Cygwin   gcc
>?:')DFFFF
Remote GroovyServ

  OFF

Only Loopback adress

Cookie
3

groovyserver
  Loopback Address

  Cookie

grovyclient
                  “localhost”=>


              A



  groovyserver

                    B

  groovyclient
GroovyServ




         GitHub          clone/fork




  Welcome

GroovyServ

  http://kobo.github.com/groovyserv
GitHub
  http://github.com/kobo/groovyserv

More Related Content

What's hot

Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL SchemaSean Chittenden
 
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)Hari
 
Security and dev ops for high velocity organizations
Security and dev ops for high velocity organizationsSecurity and dev ops for high velocity organizations
Security and dev ops for high velocity organizationsChef
 
2011-03 Developing Windows Exploits
2011-03 Developing Windows Exploits 2011-03 Developing Windows Exploits
2011-03 Developing Windows Exploits Raleigh ISSA
 
Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++corehard_by
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Eric Hogue
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHPEric Hogue
 
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Tzung-Bi Shih
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDDEric Hogue
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingEric Hogue
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Данил Иванов
 
Piratte installation
Piratte installationPiratte installation
Piratte installationKampa Lavanya
 
Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)Susan Potter
 
Node.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterNode.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterSimen Li
 
Come configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleCome configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleAntonio Musarra
 

What's hot (20)

Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL Schema
 
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
 
Security and dev ops for high velocity organizations
Security and dev ops for high velocity organizationsSecurity and dev ops for high velocity organizations
Security and dev ops for high velocity organizations
 
2011-03 Developing Windows Exploits
2011-03 Developing Windows Exploits 2011-03 Developing Windows Exploits
2011-03 Developing Windows Exploits
 
Learning Dtrace
Learning DtraceLearning Dtrace
Learning Dtrace
 
Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHP
 
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDD
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous Testing
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
 
Piratte installation
Piratte installationPiratte installation
Piratte installation
 
Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)
 
Node.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterNode.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitter
 
Come configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleCome configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per Oracle
 
Zone IDA Proc
Zone IDA ProcZone IDA Proc
Zone IDA Proc
 
Code as Risk
Code as RiskCode as Risk
Code as Risk
 
Shell Script
Shell ScriptShell Script
Shell Script
 

Similar to GroovyServ - Technical Part

What the CRaC - Superfast JVM startup
What the CRaC - Superfast JVM startupWhat the CRaC - Superfast JVM startup
What the CRaC - Superfast JVM startupGerrit Grunwald
 
Jenkins and Groovy
Jenkins and GroovyJenkins and Groovy
Jenkins and GroovyKiyotaka Oku
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneDroidConTLV
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinJava User Group Latvia
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)aragozin
 
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS clustercommit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS clusterJakub Kulhan
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldtcurdt
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerVodqaBLR
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsCloudera, Inc.
 
Год в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияГод в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияdefcon_kz
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기경주 전
 

Similar to GroovyServ - Technical Part (20)

What the CRaC - Superfast JVM startup
What the CRaC - Superfast JVM startupWhat the CRaC - Superfast JVM startup
What the CRaC - Superfast JVM startup
 
Jenkins and Groovy
Jenkins and GroovyJenkins and Groovy
Jenkins and Groovy
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)
 
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS clustercommit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real world
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteer
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to Coprocessors
 
Год в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияГод в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участия
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 

More from Yasuharu Nakano

Java開発の強力な相棒として今すぐ使えるGroovy
Java開発の強力な相棒として今すぐ使えるGroovyJava開発の強力な相棒として今すぐ使えるGroovy
Java開発の強力な相棒として今すぐ使えるGroovyYasuharu Nakano
 
OSS Product feat. Gradle
OSS Product feat. GradleOSS Product feat. Gradle
OSS Product feat. GradleYasuharu Nakano
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginYasuharu Nakano
 
The report of JavaOne2011 about groovy
The report of JavaOne2011 about groovyThe report of JavaOne2011 about groovy
The report of JavaOne2011 about groovyYasuharu Nakano
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyYasuharu Nakano
 
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」Yasuharu Nakano
 
JavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring RooJavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring RooYasuharu Nakano
 

More from Yasuharu Nakano (9)

Java開発の強力な相棒として今すぐ使えるGroovy
Java開発の強力な相棒として今すぐ使えるGroovyJava開発の強力な相棒として今すぐ使えるGroovy
Java開発の強力な相棒として今すぐ使えるGroovy
 
OSS Product feat. Gradle
OSS Product feat. GradleOSS Product feat. Gradle
OSS Product feat. Gradle
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
 
The report of JavaOne2011 about groovy
The report of JavaOne2011 about groovyThe report of JavaOne2011 about groovy
The report of JavaOne2011 about groovy
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
 
How about Gradle?
How about Gradle?How about Gradle?
How about Gradle?
 
Groovy's Builder
Groovy's BuilderGroovy's Builder
Groovy's Builder
 
JavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring RooJavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring Roo
 

Recently uploaded

Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 

Recently uploaded (20)

Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 

GroovyServ - Technical Part

  • 3.
  • 4.
  • 5. based on: Ver 0.4-SNAPSHOT(7/24)
  • 6.
  • 7. !"#$%&'()* based on: Ver 0.4-SNAPSHOT(7/24)
  • 9. GroovyServer main()
  • 10. ServerSocket Listen 1961
  • 11. $ groovyclient -e “println(‘Hello, GroovyServ!’)” groovyclient 1961(default) groovyserver
  • 12. RequestWorker start()
  • 13. ClientConnection#openSession() InvocationRequest
  • 14. groovyclient Groovy
  • 16. +,-./012345 67389:3467;5 <=6#+,4 based on: Ver 0.4-SNAPSHOT(7/24)
  • 18. GroovyServer main()
  • 21. ServerSocket Listen 1961
  • 22. $ groovyclient -e “println(‘Hello, GroovyServ!’)” ./groovy/groovyserv/cookie Cookie groovyclient Cookie: 425ba835cb32688b1 1961(default) groovyserver
  • 23. Socket Loopback Address RequestWorker
  • 24. RequestWorker ClientConnection CientConnection ThreadGroup Singleton
  • 25. RequestWorker start()
  • 26. ClientConnection#openSession() InvocationRequest Cookie
  • 27. groovyclient System.in
  • 28. groovyclient Groovy
  • 29. groovyclient (CWD) JVM 1. “user.dir” 2. JNA JVM CWD 3. CWD
  • 32. - (CWD) CTRL+C
  • 33. - (CWD) CTRL+C
  • 34. - System.out(err) System.in HTTP
  • 35. System.out(err) !script" println “Hello, GroovyServ!” Socket System.out OutputStream#write() ClientConnection (StreamResponse OutputStream) OutputStream ClientConnectionRepository groovyclient ThreadGroup ClientConnection if Channel ==”out” if Channel ==”err” " " Hello, GroovyServ!
  • 36. groovyclient StreamRequestHandler Socket.inputStream.read() pipedOutputStream.write() ClientConnection PipedOutputStream ClientConnection Repository ThreadGroup ClientConnection PipedInputStream ClientConnection System.in PipedInputStream (StreamRequestInputStream) System.in !script" System.in.eachLine { ... }
  • 37. Piped [ ] Size:-1 [ A] StreamRequestInputStream Socket#getInputStream() System.in [ B] StreamRequestInputStream PipedInputStream()
  • 38. Request InvocationRequest Groovy StreamRequest Response StreamResponse
  • 39. InvocationRequest 'Cwd:' <cwd> LF 'Arg:' <argn> LF 'Arg:' <arg1> LF 'Arg:' <arg2> LF 'Cp:' <classpath> LF 'Cookie:' <cookie> LF LF where: <cwd> is current working directory. <arg1><arg2>.. are commandline arguments(optional). <classpath>.. is the value of environment variable CLASSPATH(optional). <cookie> is authentication value which certify client is the user who invoked the server. LF is line feed (0x0a, 'n').
  • 40. StreamRequest 'Size:' <size> LF LF <data from STDIN> where: <size> is the size of data to send to server. <size>==-1 means client exited. <data from STDIN> is byte sequence from standard input.
  • 41. StreamResponse 'Status:' <status> LF 'Channel:' <id> LF 'Size:' <size> LF LF <data for STDERR/STDOUT> where: <status> is exit status of invoked groovy script. <id> is 'out' or 'err', where 'out' means standard output of the program. 'err' means standard error of the program. <size> is the size of chunk. <data from STDERR/STDOUT> is byte sequence from standard output/error.
  • 42. - (CWD) CTRL+C
  • 43. Cookie / Loopback only 2 Only from Loopback address InetAddress#isLoopbackAddress() Cookie Loopback address NG HTTP Cookie ~/.groovy/groovyserv/ cookie Cookie Authentication failed
  • 44. - (CWD) CTRL+C
  • 45. CLASSPATH CLASSPATH InvocationRequest Cp GroovyMain2 “groovy.classpath” GroovyMain2 groovy.classpath groovyserver -r -cp InvocationRequest Arg GroovyMain2
  • 46. - (CWD) CTRL+C
  • 47. CWD(Current Working Directory) Java GroovyServ CWD CWD $ cd /tmp $ groovyserver -r $ cd /home/kobo $ cat > hoge.txt HOGE!! ^C $ groovyclient -e ‘println(new File(“hoge.txt”).text)’ Caught: java.io.FileNotFoundException: hoge.txt (No such file or directory) ...SNIP...
  • 48. “user.dir” File#getAbsolutePath() “"user.dir", which is initialized during jvm startup, should be used as an informative/readonly system property” posted 2008-08-18 http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4117557 JNA JVM CWD “user.dir” FileInputStream CWD Groovy
  • 49. JNA cwd POM <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> <version>3.2.2</version> </dependency> # OK import com.sun.jna.Library import com.sun.jna.Native import com.sun.jna.Platform interface CLibrary extends Library { String libname = (Platform.isWindows() ? "msvcrt" : "c") CLibrary INSTANCE = Native.loadLibrary(libname, CLibrary.class) int chdir(String dir) int _chdir(String dir) }
  • 50. - (CWD) CTRL+C
  • 51. groovyserver Windows groovyserver.bat PID Linux/MacOSX PID kill Windows Address already in use BAT PID
  • 52. - (CWD) CTRL+C
  • 53. CTRL+C groovyclient CTRL+C “Size: -1” StreamRequestHandler
  • 54. - (CWD) CTRL+C
  • 55. java.util.concurrent 2 StreamRequestHandler Groovy GroovyInvokeHandler
  • 56. NW Groovy CTRL+C
  • 58.
  • 59. Maven + GMaven Maven + GMaven GMaven Gradle Gradle 0.4-SNAPSHOT groovy groovyc JDK API private IncompatibleClassChange Error
  • 60. IntegrationTest GroovyServ groovyclient maven-failsafe-plugin “mvn integration- test” http://maven.apache.org/plugins/maven-failsafe-plugin/ index.html mvn
  • 61. How to Build Maven2 $ cd groovyserv-<Version> $ mvn clean verify : target/groovyserv-<Version>-<OS>-<arch>-bin.zip Integration-Test target/groovyserv-<Version>-<OS>-<arch>.dir/groovyserv-<Version>-<OS>-<arch> : EncodeIT UTF-8 $ export _JAVA_OPTIONS=-Dfile.encoding=UTF-8 $ mvn -Dmaven.test.skip=true clean package Windows Cygwin gcc
  • 63. Remote GroovyServ OFF Only Loopback adress Cookie
  • 64. 3 groovyserver Loopback Address Cookie grovyclient “localhost”=> A groovyserver B groovyclient
  • 65.
  • 66. GroovyServ GitHub clone/fork Welcome GroovyServ http://kobo.github.com/groovyserv GitHub http://github.com/kobo/groovyserv