Contents 목차

  • NailGun Introduction NailGun의 소개
  • Rationale for Porting 포팅에 대한 근거
  • Compiler choice: MinGW versus CygWin 컴파일러를 선택 : mingw 대 cygwin
  • Mini Porting guide from Linux to Windows (networking focussed) 미니 포팅 가이드에서 리눅스를 창 (집중되는 네트워킹)
  • Testing 테스트
  • Code & Executable Download 코드 및 실행 파일을 다운로드
  • Suggestions for improving NailGun NailGun의 제안을 개선하기위한


NailGun Introduction NailGun의 소개

I was intrigued by the concept of 나는의 개념에 관심을가 nailgun NailGun의 which provides a way to run small Java apps significantly faster than the current procedure (load the jvm, run the app, upload the jvm). 작은 자바 애플 리케이션을 실행하는 방법을 제공하는 것보다 훨씬 빨리 현재의 절차 (로드하는 jvm, 응용 프로그램을 실행합니다 업로드하면 jvm). The main issue with using the Sun JVM (java.exe) is the startup time of the JVM. jvm을 사용하여 태양의 주요 문제 (java.exe)는 jvm의 시작 시간을합니다. For long running applications it is a non-issue, however for short running ones… 오랫동안 실행중인 응용 프로그램이 아닌 - 문제를 해결하려면 그러나 것들을 실행에 대한 짧은…
Note that Sun too has recently made some improvements by caching the jars of an application to reduce the startup time for bigger applications. 참고 : 개선하여 그 태양은 너무는 최근에 캐시를 좀 만들어 단지에 대한 응용 프로그램의 시작 시간을 줄이기 위해 더 큰 응용 프로그램을합니다. That still doesn’t address the startup time issue. 주소가 아직 시작 시간 문제가되지 않습니다. So I think the solutions are complementary. 그래서 내 생각에 그 솔루션은 상호 보완합니다. It would be interesting if someone can do a benchmark on Windows. 그것은 재미있는 누군가 벤치 마크를 할 수 windows.

The key concept of NailGun is that a Java server keeps running in the background and a small executable client ( written in C for speed ) is used to send the application details to the server for execution, details like application class name, command line arguments etc. NailGun의 핵심 개념은 백그라운드에서 실행되고있는 자바 서버 유지와 작은 실행 파일 클라이언트 (작성된 c에 대한 속도)를 사용하여 서버에 대한 세부 정보를 보내는 응용 프로그램을 실행, 세부 사항 같은 응용 프로그램 클래스 이름을 명령줄 인수를 비고 합니다.

As you can see from the above web page it can significantly speed up the startup time. 웹 페이지에서 볼 수있습니다 이상으로 그것에 박차를 시작 시간을 크게합니다. Also repeated running will conceivably further improve performance as the classes are already loaded in the JVM. 이대로는 성능을 향상도를 반복적으로 실행하는 클래스가 이미로드의 jvm합니다.

This is ideally suited for small command line applications like grep, wc, sort etc. , more so when you want to do some processing in a loop. 이것은 소규모의 커맨드 라인 응용 프로그램처럼 적합합니다 grep, 화장실, 정렬 등의 작업을 할 때 더욱 그렇다 루프합니다.

Rationale for porting & Why me? 에 대한 근거로 포팅 & 왜 나를?
I think it can prove to be an useful tool in your toolbox specially for windows programmers as windows lack several useful command line utilities which can be trivially implemented (and has been implemented in many cases) in Java. 증명할 수있는 것 같아요 도구 상자에 유용한 도구가 될 windows 프로그래머를 위해 특별히 windows 부족 자명 수있는 여러 유용한 명령줄 유틸리티 구현 (그리고 많은 경우에 구현되었습니다)에 자바.

I lead a massive porting effort 8 years back of porting over a million lines of C code (running on Solaris, AIX & Mac) to windows nt and windows 3.1. 나는 거대한 포팅 노력을 8 년간 이끌 100 만 개 이상의 포팅 뒷면 c 줄의 코드 (실행중인 솔라리스, aix & 맥)을 windows 2000 및 창 3.1. I had to deal with socket issues among a host of other. 소켓 문제를 다루는 나는 사이의 호스트의 다른합니다. However it was on MSVC & Borland compilers. 그러나 msvc & 보랜드 컴파일러에 있었는데합니다.
So I thought yesterday to try my hand at porting some code on 그래서 난 내 손을 생각을 시도하기 위해 어제 일부에 코드를 포팅 MinGW mingw . 합니다. My incentive was to re-hash the experience I had gained and hopefully learn some more. 내 동기는 - 해시의 경험을 다시 얻고, 아마 나는 좀 더 자세히합니다.

Why MinGW? 왜 mingw?

I avoided 난 교묘히 Cygwin cygwin because of its dependence on cygwin dll and cygwin dll의 의존도 때문에, licensing 라이센스 issues. 문제가있습니다. Nailgun is on Apache license. NailGun의는 아파치 라이선스합니다. Cygwin is on GPL. cygwin은 GPL를합니다. This will force the executable to have more restrictive license than the original intention which is not desired. 이것은 강제로 실행 파일을 좀 더 많은 제한이 라이선스의 원래 목적이 아닌보다 희망합니다.

Mini Porting guide from Linux to Windows (networking focussed) 미니 포팅 가이드에서 리눅스를 창 (집중되는 네트워킹)
Several networking related Linux headers files are not available in Windows. 헤더 파일은 여러 네트워크 관련 리눅스는 창. Instead winsock.h or winsock2.h is a good replacement for them. 대신에 그들을 위해 winsock.h 또는 winsock2.h는 좋은 보충합니다. You can use the following template: 다음과 같은 템플릿을 사용할 수있습니다 :

 #ifdef WIN32 #include # ifdef win32 # 포함  #else #include # 다른 # 포함  #include # 포함  #include # 포함  #include # 포함  #include # 포함  #endif # endif 

The file separator is different as you all know: 구분 기호가 서로 다른 파일을 모두들 아시 :

 #ifdef WIN32 #define FILE_SEPARATOR '' #define MSG_WAITALL 0 #else #define FILE_SEPARATOR '/' #endif # ifdef win32 # file_separator '' # 정의를 정의를 정의 msg_waitall 0 # 다른 # file_separator '/'# endif 

Oh yes, MSG_WAITALL is not defined in Windows. 오, 그래!에 msg_waitall가 정의되지 windows. The value 0 serves the purpose. 의 목적의 값을 0 제공합니다.

Windows implements Berkeley Socket in a half-hearted way. 버클리 소켓에 windows 30 - 마음 방법을 구현합니다. It requires invoking WSAStartup before making any socket calls. 모든 소켓을 호출 전화를 걸기 전에 wsastartup이 필요합니다. This is obviously not a requirement in Unix/Linux systems. 이것은 분명하게 요구 사항을 유닉스 / 리눅스 시스템합니다. A template code can be as follows: 템플릿 코드는 다음과 같습니다 :

 #ifdef WIN32     WSADATA wsaData;     WORD wVersionRequested;     int err;      wVersionRequested = MAKEWORD( 2, 0 ); // 2.0 and above version of WinSock     err = WSAStartup( wVersionRequested, &wsaData );     if ( err != 0 ) {         fprintf(stderr, "Couldn't not find a usable WinSock DLL.n");         exit(NAILGUN_CONNECT_FAILED); // Replace with your own exit code     } #endif # ifdef win32 wsadata wsadata; 단어 wversionrequested; int 오류; wversionrequested = makeword (2, 0); / / 2.0 이상의 버전에 대한 winsock 오류 = wsastartup (wversionrequested, & wsadata); 경우 (오류! = 0) (fprintf (stderr, "쓸만한 수없습니다 winsock dll.n 찾을 수없습니다"); 출구 (nailgun_connect_failed); / / 교체하여 자신만의 종료 코드) # endif 

Winsock version 2.0 and above is required for 버전 2.0 이상이 필요합니다 winsock select 선택 functionality. 기능을합니다.

And don’t forget to cleanup when done: 그리고 정리 작업이 완료되면 잊지 마세요 :

 #ifdef WIN32  WSACleanup(); #endif # ifdef win32 wsacleanup (); # endif 

select 선택 doesn’t work on files under windows. 파일을 윈도우에서는 작동하지 않습니다. This is a major difference from Unix/Linux systems where files are treated as sockets. 이것은 큰 차이가 유닉스 / 리눅스 시스템에서 파일이 소켓을 취급합니다. Hence implemneting non-blocking calls on Windows becomes a hassle. 따라서 통화를 차단 windows - implemneting 아닌 통로가됩니다. For I/O from console kbhit() can be used to find there was a key press (except certain control keys) and then getch() (no echo) or getche() can be used to fetch the characters. 에 대한 내 / 오에서 콘솔을 kbhit ()가 열쇠를 찾을 수있습니다 프레스 (제외하고 특정 제어 키)를 누른 getch () (아니오 에코) 또는 getche ()를 가져오려면 문자를 사용할 수있습니다. However the same technique doesn’t work when another program is using a pipe to send data to this program. 그러나 동일한 기법이 작동하지 않습니다을 보낼 때 파이프를 사용하는 다른 프로그램이 데이터를이 프로그램을합니다. Then overlapped I/O (Windows name for non-blocking I/O) can be used (ReadFile() or ReadFileEx()). 다음 중복 / 오 (windows 이름을가 아닌 - 블로킹 입 / 출력) 사용할 수있습니다 (readfile () 또는 readfileex ()). ReadFileEx() is used for overlapped I/O only, whereas ReadFile() is used for both. readfileex ()를 사용하는 중복 / 또는 전용, 반면 readfile ()은 둘 다 사용합니다.

I found a 찾았습니다 good article 좋은 기사 which is better than Microsoft documentation on the subject. 마이크로 소프트는 문서가이 주제에 더 나은합니다.

This is one part where the port is incomplete. 이것은 하나의 포트 부분이 불완전합니다. It handles keyboard input well. 키보드 입력 잘 처리합니다. However it doesn’t handle piped inputs. 그러나 유선 입력을 처리하지 않습니다. I leave it as a challenge for anyone who wants to gather experience on async file I/O in Windows platform. 나는 그것을 떠나지를 수집하는 경험을 원하는 사람의 애로 사항에 대하여 비동기 파일 입 / 출력이 윈도우 플랫폼합니다.

perror() doesn’t work for Socket calls. perror () 기능이 작동하지 않습니다 소켓 호출합니다. WSAGetLastError() must be used to get the error, if any, in the last socket call. wsagetlasterror ()의 오류를 사용해야합니다 경우, 지난 소켓 호출합니다.
Note that for File I/O etc. GetLastError() returns the error code. 참고하는 파일 입 / 출력 등 GetLastError가 ()의 오류 코드를 반환합니다.

For other details you can refer to Microsoft porting guide 기타 세부 사항을 참조하실 수있습니다 microsoft 포팅 가이드 guide 안내서 . 합니다.

Interestingly the guide is silent on the above mentioned critical issues of porting. 이 안내서는 위를 흥미롭게 중요한 문제에 침묵 포팅합니다.

Final Notes: 마지막 참고 사항 :
1. Always remember to check and possibly handle the error codes. 항상 기억의 오류 코드를 확인하고 처리할 수있습니다.
2. 두합니다. Remember to close the sockets before exiting 소켓을 종료하기 전에 기억을 닫으려면

Testing 테스트

The code has been tested only on Windows 2000 Professional. 이 코드는 windows 2000에서만 테스트합니다.

However I think it should work well on Windows NT and XP versions. 그러나 내 생각에 그것은 windows 2000 및 XP 용 버전을 잘 작동합니다. About Windows 98 (Is it an Operating System or just a game playing console?) and Windows ME I am not too sure. 에 대한 windows 98 (가 그것을 운영 체제 또는 단순한 게임 콘솔을?)와 windows 나 나는 너무 확실합니다.

Where do I get it? 어디서 났니?
I have made available the 나는 이용할 수 the source code of the C port of ng.c (client) c 포트의 소스 코드 ng.c (클라이언트) and the resulting 그리고 그 결과 executable 실행 파일 for invoking nailgun server. NailGun의 서버에 대한 호출합니다. The rest should be downloaded from 나머지는되어야에서 다운로드 Source Forge 소스 포지 . 합니다. The executable has been checked with AVG Virus Scanner with latest update installed. 평균의 실행 파일은 바이러스 스캐너와 최신 업데이 트를 설치와 확인을합니다. However I insist that you too check it with your virus scanners. 그러나 나는 그것을 주장하고 귀하의 바이러스 스캐너 당신도 확인합니다.

Note: 참고 사항 :
The orginal code was developed by Martian Software. 화성의 원래 코드가 개발한 소프트웨어를합니다. I just ported it to Windows. 단지 그것을 포팅 windows.

Disclaimer: 면책 조항 :
The code and executable software is supplied “as is”. 실행 파일의 코드와 소프트웨어가 공급 "있는 그대로"합니다. The publisher disclaims all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. 게시자는 상품성, 명시적 또는 묵시적을 포함하며 이에 제한, 및 적합성에 대한 묵시적 보증을 목적합니다. The publisher assumes no liability for damages, direct or consequential, which may result from the use of the provided code or executable or any other software program downloaded from the Website. 게시자에 대한 책임을지지 않습니다 손해, 직접 또는 파생적, 어느가 발생할 수있습니다에서 제공된 코드 또는 실행 파일의 사용이나 다른 소프트웨어 프로그램을 웹 사이트에서 다운로드합니다. The entire risk as to the quality and performance of the software is with you, and you assume the entire cost of any necessary servicing, repair or correction. 전체를 위험은 소프트웨어의 품질과 성능을가 당신에게, 그리고 당신의 전체 비용은 추측에 필요한 서비스, 수리 또는 수정합니다.

Please check the 을 확인하십시오 instructions 지침 . 합니다.

Suggestions for improving NailGun NailGun의 제안을 개선하기위한
1. Allow recognizing -cp (and other Java options) and load the classes dynamically 허용 인식 - cp (및 기타 자바 옵션) 및 부하의 클래스를 동적으로
2. 두합니다. Is it using a Thread Pool? 이 나사를 사용하여 수영장 은요? If not it should be used 그렇지 않으면 그것을 사용해야합니다
3. 3합니다. Ability to reload classes 능력 클래스를 다시로드
4. 사. Ability to modify classes to disable System.exit and make the server more robust 능력을 수정할 클래스를 사용하여 서버에 더 강력한을 해제하고 system.exit
5. 오. Use a Java client and compile using MinGW on Windows mingw를 사용하는 자바 클라이언트를 사용하여 컴파일 windows