Wednesday, 27 April 2016

[RCP] How to add recently opened editors menu.(최근 열은 에디터(파일) 리스트 메뉴 추가)

In ApplicationActionBarAdvisor.class

Sample Code
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
        @Override
 protected void fillMenuBar ( IMenuManager menuBar) {
  MenuManager fileMenu = new MenuManager("&File", "pe.dorbae.rcp.sample.file");
  menuBar.add( fileMenu);
  fileMenu.add( ContributionItemFactory.REOPEN_EDITORS.create( this.mWindow));
  fileMenu.add( new Separator());
  
  // Using plugin.xml
  
 }

[RCP] How to execute command programmatically in Eclipse RCP.(코드로 Command를 실행)

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
IHandlerService handlerService = (IHandlerService) HandlerUtil.getActiveSite( event).getService( IHandlerService.class);
ICommandService commandService = (ICommandService) HandlerUtil.getActiveSite( event).getService( ICommandService.class);

// Retrieve the command
Command generateCmd = commandService.getCommand( OpenNewSCPEditorAction.ID);

// Create an ExecutionEvent and specify the IFile associated
ExecutionEvent executionEvent = handlerService.createExecutionEvent(generateCmd, new Event());
            
// Launch the command
try {
    generateCmd.executeWithChecks( executionEvent);
                
} catch ( Exception e) {
    LOG.error( "Failed to open new scp editor.\n{}", ExceptionUtils.getStackTrace( e));
                
}

Tuesday, 19 April 2016

[RCP] How to Build Multiple Platform in Eclipse Mars (Eclipse Mars 이후 버전 Multiple Platform 설정)

 Eclipse RCP는 하나의 Source로 다양한 Platform(Windows/x86, Linux/x86, Linux/ppc, AIX/ppc, HP-UX/ia64, MACOSX/x86, Solais/Sparc)에 맞춰 빌드할 수 있다.
 Mars(4.5) 버전 이전에는 개발하는 Eclipse 버전에 맞는 delta pack을 다운로드 받아 Target Platform에 추가해줬다. 그러나 Mars 이후로는 더 이상 delta pack을 지원하지 않는다.

 Previously, before the Mars release, you could install the RCP delta pack in your Target Platform (which was downloadable as a zip file, from the download page).
 In the Mars release, that delta pack zip file is no longer available on the download page. The reason for removing it was that p2 can be used instead, so it saves complications in the Platform build, and does not take up redundant space making the same stuff available in multiple ways.

Way to build multi-platform in Mars


1. Open Window/Preferences.

2. Find PDE/Target Platform
3. Select your (active) target platform
4. Click Edit

5. Click Add






















6. Select "Software Site" and Click Next















7. Click Next
In "Work With" type: http://download.eclipse.org/eclipse/updates/4.5 (replace 4.5 with your current version)









8. Check "Eclipse RCP Target Components", "Equinox Target Components", "Include all environments" and Uncheck "Include required software"
































9. Open your product file and select the "Export" option.




10.You will see that the "Export for multiple platforms" checkbox is available.



















11. Check platform(s) you want to build.

Monday, 11 April 2016

[Xen] How to check CPU information.(CPU 정보 확인)

The Host CPU can be viewed using the xe host-cpu-info CLI command since XenServer 5.6

xe host-cpu-info




[Xen] How to import VM image using xe command.

Import the VM using the following xe command

xe vm-import filename=[VM File Path] force=true sr-uuid=<uuid of desitination SR> preserve=true

Saturday, 2 April 2016

[JMS] JMS Message Structure.(Java Message Service 메시지 구조)

JMS(Java Message Service) Message Structure


1. Message Header

1.1. JMSDestination
 The destination to which the message is being sent—for example, Queue or Topic. Its value is set by the provider after completion of the send and matches the destination associated with the MessageProducer. A getter method is defined to allow the receiving application to access the value of JMSDestination. However, although a setter method is provided, the value of JMSDestination is ignored during a send.

1.2. JMSDeliveryMode
 JMSDeliveryMode is used to define the persistence of a message. A nonpersistent message is not logged to a persistent message store by the provider, implying that the message cannot be recovered in the event of a provider process failure. Persistent messages, on the other hand, are logged and are thus recoverable by the provider when it restarts. JMSDeliveryMode holds an integer value defined by the interface DeliveryMode. DeliveryMode contains two static integer values: NONPERSISTENT and PERSISTENT. The value of JMSDeliveryMode is set by the provider after completion of the send. It is based on the value specified by the sending method, which can be either DeliveryMode.NONPERSISTENT or DeliveryMode.PERSISTENT. The provider defaults to persistent delivery if no value is specified. As with JMSDestination, any value set by the setter method is ignored on send. A getter method provides access to the populated value.

1.3. JMSMessageID
 JMSMessageID uniquely identifies a message. It is defined as a String and ignored if set when the message is sent. It is populated with a provider-assigned value on completion of the send. The provider-assigned identifier is prefixed with ID:.

1.4. JMSTimestamp
 The JMSTimeStamp field is populated by the provider during the send; the value set is in the format of a normal Java millisecond time value.

1.5. JMSExpiration
 JMSExpiration stores the expiration time of the message. This is calculated as the current time plus a specified timeToLive. The value of timeToLive is specified on the sending method in milliseconds, and the provider populates JMSExpiration (type Long) with the computed value in milliseconds on completion of the send. If a value for timeToLive is not specified or is specified as zero, JMSExpiration is set to zero, signifying that the message does not expire. Any value set for JMSExpiration is ignored on the send. Once a message has expired, the JMS client is unable to retrieve the message. Typically, the message is discarded by the provider at this point. JMSExpiration provides a convenient way to clean up messages that have a well-defined relevance period, such as a reply to a request that has arrived late.

1.6. JMSRedelivered
 The JMSRedelivered field takes a Boolean value set by the provider to signify that the message has been previously delivered to the client. It is only relevant when consuming a message and serves to alert the client (if checked) that it has previously attempted processing of this message. Recall from our discussion of message consumers and "poison" messages in Chapter 1, "Enterprise Messaging," that JMSRedelivered can help address the issue of infinite repeated processing, which could occur if the message is being processed within a transaction and being redelivered because processing failed.

1.7. JMSPriority
JMS defines transmission priority levels 0 to 9, with 0 as the lowest priority and 9 as the highest. It additionally specifies that priorities 0 to 4 should be considered gradations of normal delivery and priorities 5 to 9 as gradations of expedited delivery. The provider populates JMSPriority (type int) on completion of the send based on the value specified by the sending method.

1.8. JMSReplyTo
JMSReplyTo is set by the client and takes as value a Destination object that specifies where replies to this message are to be sent. This implies that this field is set only if a reply is required. By default it is set to null.

1.9. JMSCorrelationID
 The JMSCorrelationID field is typically used to link two messages together. For example, in order to link a given reply to a request, the JMS client could specify that the JMSCorrelationID of the incoming reply should match the JMSMessageID of the sent request. This requires the servicing client to set the JMSCorrelationID of the reply to the JMSMessageID of the request before sending the reply. Consequently, if used, this field is set by the JMS client.
 JMS additionally allows for the case where the JMS client needs to use a specific value for linking messages; in this case an alternative string value can be set, but it should not be prefixed with ID:. If the JMS client is servicing a request from a non-JMS client and needs to assign a specific value for use with such clients, JMS defines a byte array optional type for JMSCorrelationID. However, providers are not required to implement support for this optional type.

1.10. JMSType
 JMSType contains a message type identifier that is set by the client. Its purpose is to enable clients of providers who provide a message definition repository to associate with the contained message body a reference to its physical format definition in the provider's message repository.

2. Message Properties

 Properties are used to add optional fields to the header. A property can be specified by the application, be one of the standard properties defined by JMS, or be provider-specific. When sending a message, properties can be set using associated setter methods. In the received message, properties are read-only, and any attempt to set the properties on a received message results in a MessageNotWriteableException. If it is desired to modify the properties of a received message—for instance, the application is performing a brokering function and needs to modify the attributes of the message before forwarding it to the next destination—then the clearProperties() method is called on the message object.

3. Message Body

3.1. TextMessage
 TextMessage stores data as a String, a common representation of enterprise data.

3.2. MapMessage
 MapMessage stores data as a set of key-value pairs. The key is defined as a string, and the value is typed—for example, Age:33, where Age is the key and 33 the integer value.

3.3. BytesMessage
 BytesMessage stores data as a sequence of bytes, supports the most basic representation of data, and thus can contain varied payloads.

3.4. StreamMessage
 StreamMessage stores data as a sequence of typed fields, for example, JohnDoe33, defined as a sequence of two strings (John, Doe), and an integer (33).

3.5. ObjectMessage
 ObjectMessage stores a serialized Java object.

[Maria/MySQL] How to check transaction isolation level and set isolation level.(트랜잭션 Isolation level 확인)

1. Check Trasaction Isolation Level

1-1. Global Level
SELECT @@global.tx_isolation;

1-2. Sesssion Level
SELECT @@tx_isolation;


2. Set Isolaction Level

2-1. Edit Configure file
[myslqd]
transaction-isolation = [READ-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE]

2-2. Using command
SET @@[SESSION | GLOBAL].tx_isolation = '[READ-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE]';

[Mraia/MySQL] InnoDB Trasaction Isolation Level

MariaDB에서는 다양한 Engine을 지원한다. 전신인 MySQL 5.5버전 이후로 MyISAM에서 InnoDB로 Default Engine으로 변경되었다.

InnoDB에서는 4가지 Isolation Level을 지원한다.

1. READ UNCOMMITED
 SELECT 명령문은 비-락킹 유형으로 실행되지만, 레코드의 예전 버전이 사용될 수도 있다. 따라서, 이러한 분리 레벨을 사용하면, 이러한 읽기 연산은 일관성을 갖지 못하게 된다. 이것을 소위 “더티 읽기 (dirty read)”라고 한다. 그렇지 않을 경우, 이러한 분리 레벨은 READ COMMITTED처럼 실행된다.

2. READ COMMITTED
 오라클과 유사한 분리 레벨. 모든 SELECT ... FOR UPDATE 및 SELECT ... LOCK IN SHARE MODE 명령문은 인덱스 레코드만을 잠그지만, 인덱스 레코드 앞에 있는 갭은 잠그지 않으며, 따라서 새로운 레코드를 잠겨 있는 레코드 다음에 자유롭게 삽입하는 것을 허용한다. 유니크 검색 조건과 함께 유니크 인덱스를 사용하는 UPDATE 및 DELETE 명령문은 찾게 되는 인덱스만을 잠그며, 인덱스 잎에 있는 갭을 잠그지는 않는다. 범위-타입 UPDATE 및 DELETE 명령문의 경우, InnoDB는 반드시 다음-키 또는 갭 잠금을 설정하고 범위 내에 있는 갭에 대해서는 다른 사용자의 삽입을 막아야 한다. 이것은 MySQL 리플리케이션과 복구가 동작하기 위해서는 “팬텀 열 (phantom rows)”이 반드시 막혀야 하기 때문이다.
 컨시스턴트 (consistent) 읽기 (consistent read)는 오라클과 동일한 동작을 실행한다: 각각의 컨시스턴트 (consistent) 읽기는, 동일한 트랜젝션 안에서라도, 자신의 최신 스냅샷을 설정하고 읽는다. Section 14.2.10.4, “컨시스턴트 (consistent) 비-락킹 (Non-Locking) 읽기”를 참조할 것.

3. REPEATABLE READ (Default)
 이것은 InnoDB. SELECT ... FOR UPDATE, SELECT ... LOCK IN SHARE MODE, UPDATE의 디폴트 분리 레벨이며,유니크 검색 조건과 함께 유니크 인덱스를 사용하는 DELETE 명령문은 발견한 인덱스만을 잠그며, 그 앞에 있는 갭은 잠그지 않는다. 다른 검색 조건을 사용하면, 이러한 연산은 다음-키 락킹을 적용하고, 다음-키 또는 갭 잠금을 사용해서 스캔한 인덱스 범위 락킹을 하며, 다른 사용자의 새로운 삽입을 막아 버린다.
 컨시스턴트 (consistent) 읽기의 경우, READ COMMITTED 분리 레벨과는 중요한 차이점이 존재한다: 동일 트랜젝션 내에서의 모든 컨시스턴트 (consistent) 읽기는 첫 번째 읽기에 의해 성립된 동일 스냅샷을 읽게 된다. 이것은, 만일 여러분이 몇몇 평이한 SELECT 명령문을 동일한 트랜젝션 안에 입력할 경우, 이러한 SELECT 명령문은 각각에 대해서도 일관성을 함께 가진다는 것을 의미하는 것이다. Section 14.2.10.4, “컨시스턴트 (consistent) 비-락킹 (Non-Locking) 읽기”를 참조할 것.

4. SERIALIZABLE
 이 레벨은 REPEATABLE READ과 유사하지만, InnoDB는 암시적으로 모든 SELECT 명령문을 SELECT ... LOCK IN SHARE MODE에 대해서 실행한다.

[Windows] System Environment Variables

Variable> Description Example
%ALLUSERSPROFILE% All users profile directoy
%APPDATA% Directory for saving application's configuration C:\Users\Administrator\AppData\Roaming
%COMMONPROGRAMFILES% Common Program Files directory C:\Program Files\Common Files
%COMPUTERNAME% Workstation name DORBAE_LAPTOP
%COMSPEC% Directory path where cmd.exe is located C:\Windows\system32\cmd.exe
%HOMEDRIVE% Local workstation drive related with user home direcoty C:
%HOMEPATH% User home directory full path \Users\Administrator
%NUMBER_OF_PROCESSORS% Count of logical processors\ 8
%OS% Operation system's name Windows_NT
%PROCESSOR_ARCHITECTURE% Kind of workstation's processor AMD64
%PROCESSOR_IDENTIFIER% Identifier of processor Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
%PROCESSOR_LEVEL% Level of processor 6
%PROCESSOR_REVISION% Revision of processor 3c03
%PROGRAMFILES% Location of program files directory C:\Program Files
%SYSTEMDRIVE% Drive where OS is installed C:
%SYSTEMROOT% Location of WINDOWS directory C:Windows
%TEMP% Temporary directory C:\Users\ADMINI~1\AppData\Local\Temp
%TMP% Temporary directory C:\Users\ADMINI~1\AppData\Local\Temp
%USERNAME% User's name Administrator
%USERPROFILE% User profile directory C:\Users\Administrator