레이블이 SpringBatch인 게시물을 표시합니다. 모든 게시물 표시
레이블이 SpringBatch인 게시물을 표시합니다. 모든 게시물 표시

2013년 8월 7일 수요일

Spring Batch JDBC - deleting table

JDBC를 통해 mysql에 있는 table의 내용을 지우는 작업을 만들었다.

먼저 custom tasklet을 빈으로 선언
  <bean id="jdbcCleanUp"
  class="my.mysql.JdbcCleanUp">
  <property name="dataSource" ref="dataSource"/>
  </bean>
----------------------------------------------------------------------------------------------------------------------
배치 작업을 설정
<batch:job id="cleanUp">
<batch:step id="cleanning">
<batch:tasklet ref="jdbcCleanUp" />
</batch:step>
</batch:job>
----------------------------------------------------------------------------------------------------------------------
custom tasklet을 작성
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

public class JdbcCleanUp extends JdbcDaoSupport implements Tasklet{

@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
// TODO Auto-generated method stub
delete();
return null;
}
public void delete() {
String[] sql = {"delete from AD_CNT_TB","delete from UNIT_CNT_TB",
"delete from OS_CNT_TB","delete from LOCATION_CNT_TB",
"delete from GENDER_CNT_TB","delete from AGE_CNT_TB"};
   getJdbcTemplate().batchUpdate(sql);
}
}

참고:http://www.java2s.com/Code/Java/Spring/UseJdbcTemplateToExecuteDeleteStatementWithParameter.htm

2013년 8월 6일 화요일

Spring Batch jobRepository 설정

나는 아래와 같이 설정을 해 놓고 사용중이었다. (mysql로 DB를 사용중)
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${batch.jdbc.driver}</value>
</property>
<property name="url">
<value>${batch.jdbc.url}</value>
</property>
<property name="username">
<value>${batch.jdbc.user}</value>
</property>
<property name="password">
<value>${batch.jdbc.password}</value>
</property>
</bean>

<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

<batch:job-repository id="jobRepository"
data-source="dataSource"
transaction-manager="transactionManager" />

<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>

위의 설정에서 불편한 점은 실제 DB에 Job Instance와 Batch 정보 등 메타데이터가 저장되기 때문에 테스트하면서 Job을 실행할 때 마다 JobParameter를 매번 바꿔야 한다는 점이다.

이 메타데이터를 실제 DB에 저장하지 않고 메모리상에서만 저장하고 사용하는 방법이 있는데 이 방법을 사용하면 매번 JobParameter를 바꾸지 않아도 되지 때문에 이 방법을 적용시켜 보았다.

아래 출처에서 나와 있는 부분으로 jobRepository 부분만 바꾸니 잘 된다. ㅠㅠ
<bean id="jobRepository"
  class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
    <property name="transactionManager" ref="transactionManager"/>
</bean>

출처: http://static.springsource.org/spring-batch/reference/html/configureJob.html

Mockito 및 looger 사용 | 스프링 배치 테스트 - 링크

Logger 사용
나는 사용하려는 클래스 안에 Logger를 변수로 추가 후 사용했다.
private final static Logger logger = Logger
.getLogger(사용하려는.class);

그리고 logger.info("텍스트"); 로 INFO 로 출력

Mockito 사용
TestClass test1 = mock(TestClass.class);

verify(test1, atLeastOnce()).testMethod(arg1, arg2);
메이븐에 디펜던시 추가
  <groupId>org.mockito</groupId>
  <artifactId>mockito-all</artifactId>
  <version>1.9.5</version>
  <scope>test</scope>

기타 - stop watch 사용
StopWatch sw = new StopWatch();
sw.start();
실행문;
sw.stop();
logger.info(">>> TIME ELAPSED:" + sw.prettyPrint());

출력
INFO [사용하려는클래스이름] - <>>> TIME ELAPSED:StopWatch '': running time (millis) = 3646
-----------------------------------------
ms     %     Task name
-----------------------------------------
03646  100%

참조
       - Mockito : https://code.google.com/p/mockito/
       - Batch Test : http://static.springsource.org/spring-batch/reference/html/testing.html
                             http://blogs.justenougharchitecture.com/?p=124

JobParameter 사용하기

http://forum.springsource.org/showthread.php?89530-Problem-with-jobParameter-in-xml-configuration-file
-> jobParameter를 사용할 Bean에 scope를 명시해야 한다. scope="step" (step에서 사용하는 bean일 때)

-> jobParameter는 value="#{jobParameters['파라미터 이름']}" 으로 사용한다.


http://blog.naver.com/PostView.nhn?blogId=kjh16241624&logNo=110172861862
-> <property name="abc" value="#{jobParameters['bcd']}" />  이렇게 설정을 했다면 해당 클래스에서 setter를 만들어야 하는데 네이밍을 public void setAbc 이렇게 해주면 된다. 프로퍼티의 네임값의 첫번째 문자만 대문자로 조정


-> 커맨드라인에서 잡 파라미터는 마지막에 파라미터이름=파라미터값 을 추가한다.
$ java -cp "target/your-project.jar" org.springframework.batch.core.launch.support.CommandLineJobRunner your-job.xml yourJob parameter.name=parameter.value

스프링 배치 예제 - 링크

1. http://www.techavalanche.com/2011/08/21/spring-batch-hello-world-in-memory/
2. http://www.techavalanche.com/2011/10/23/spring-batch-itemreader-and-itemwriter/

Custom Tasklet - with Java

import org.apache.hadoop.util.ToolRunner;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;

public class MyTasklet implements Tasklet{
private String 변수1;
private String 변수2;
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
// TODO Auto-generated method stub
int exitCode=0;
String paths[] = 변수지정;
exitCode = ToolRunner.run(new 하둡의드라이버(), paths);
System.exit(exitCode);
return null;
}
public MyTasklet(String 변수1, String 변수2) {
        this.변수1 = 변수1;
        this.변수2 = 변수2;
    }
}

----------------------------------------------------------------------------------------------------------------
이렇게 custom tasklet을 만들고 해당 클래스를 bean으로 만들어서
배치작업에서 사용하면 된다.

빈 설정
<bean id="myCustomTasklet"
  class="com.custom.test.MyTasklet">
    <constructor-arg type="String" value="변수1" />
      <constructor-arg type="String" value="변수2" />
</bean>

배치 작업 설정
<batch:job id="job1">
<batch:step id="step1">
<batch:tasklet ref="myCustomTasklet" />
</batch:step>
</batch:job>

----------------------------------------------------------------------------------------------------------------------
테스트를 위해 자바로 배치 작업을 실행한다면
import java.util.Date;

import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class RunJob {
public static void main(String[] args) throws Throwable {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("배치작업있는.xml");
ctx.start();
JobLauncher jobLauncher = (JobLauncher) ctx.getBean("jobLauncher");
Job dbJob = (Job) ctx.getBean("job1");
JobExecution jobExecution = jobLauncher.run(dbJob, new JobParametersBuilder().addDate("date", new Date()).toJobParameters());
//JobParameter를 지정해야 작업이 실행된다. 여기서는 날짜를 변수로 넣었고 해당 변수는 사용하지 않았다
JobInstance jobInstance = jobExecution.getJobInstance();
System.out.println("job instance Id: " + jobInstance.getId());
//테스트를 위해 작업 번호를 출력
BatchStatus batchStatus = jobExecution.getStatus();
while(batchStatus.isRunning()) {
System.out.println("Strill running...");
Thread.sleep(10*1000);//10sec
//작업이 진행중임을 확인하기 위한 예제
}
}
}

참고: http://static.springsource.org/spring-hadoop/docs/current/reference/html/fs.html
http://static.springsource.org/spring-hadoop/docs/current/reference/html/hadoop.html#hadoop:tool-runner
http://static.springsource.org/spring-batch/reference/html/configureJob.html#runningJobsFromCommandLine
http://www.mkyong.com/spring-batch/run-spring-batch-job-with-commandlinejobrunner/

파일 필터링 및 하둡으로 로컬파일 복사

로컬 파일 필터링 출처: http://mudchobo.tistory.com/355
File file=new File("폴더의 경로");
String[] list = file.list(new FilenameFilter()
       {
           @Override
           public boolean accept(File dir, String name)
           {
               return name.startsWith("My.Log");
           }
       });

My.Log로 시작하는 파일을 주어진 폴더(경로)에서 찾아 이름만 반환한다.

        for (int i = 0; i < list.length; i++)
       {
                localSrc="폴더의경로".concat(list[i]);
dst = "복사할경로".concat(list[i]);
in = new BufferedInputStream(new FileInputStream(localSrc));

fs = FileSystem.get(URI.create(dst), conf);
if(fs.exists(new Path(dst))) {
fs.delete(new Path(dst), true);
}
out = fs.create(new Path(dst), new Progressable() {
//64kb 의 데이터 패킷이 데이터 노드 파이프라인에 쓰일 때 마다 하둡에 의해 progress() 메소드가 호출, 마침표를 프린트
public void progress(){
System.out.print(".");
}
});
IOUtils.copyBytes(in,out,4096,true);
       }

폴더의 경로에 파일 이름을 붙여서 파일의 경로를 만들고 복사할 경로에 파일 이름을 붙여서 복사할 위치의 경로를 만들었다.
그리고 IOUtils를 이용해서 출력

참고: http://byulbada.egloos.com/2232184 (BufferedInput/Output)
          http://k.daum.net/qna/openknowledge/view.html?qid=40E1d (파일 필터링)

2013년 8월 5일 월요일

crontab 사용 및 배치 스크립트

배치 스크립트 예제: http://www.lucasward.net/2010/07/spring-batch-deployment-example.html
#!/bin/bash

CP=실행할xml이있는폴더/

LIB=프로젝트의라이브러리들이있는폴더/*
for f in $LIB
do
CP=$CP:$f
done

java -cp $CP org.springframework.batch.core.launch.support.CommandLineJobRunner \
예제잡파일.xml 예제잡이름

크론탭 사용 예제: http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

XML 파일에 스크립트를 삽입시켜 사용할 수 있다.
 <hdp:script id="adSetUp" language="javascript" run-at-startup="false">
     //importPackage(java.util);
     
     inputPath = "/로컬파일주소"
     outputPath="/hdfs로 복사할 주소"
     if(fsh.test(outputPath)) {
      fsh.rmr("file://".concat(outputPath))
     }
     if(fsh.test(inputPath)) {
      fsh.get(inputPath,outputPath)
       }
   </hdp:script>
이 스크립트는 스크립트 id를 job id처럼 호출 하면 된다. 혹은 run-at-startup 항목을 true로 하면 자동 실행된다.

Unable to locate Spring NamespaceHandler for XML schema namespace

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [launch-context.xml]

이런 에러가 뜨면서 내가 만든 배치 잡이 실행되지 않는다.
maven을 통해서 라이브러리를 함께 넣어서 jar 파일을 만들었다.
내가 찾은 해결책은 맨 아래를 참조 바람.


http://rgordon.co.uk/blog/2012/01/20/getting-started-with-spring-batch/
위의 블로그에서는 이클립스 플러그인 m2e에서 dependency copy가 되지 않아서 명령어로 직접 lib를 넣은 것이다.

http://stackoverflow.com/questions/17099438/unable-to-locate-namespacehandler-for-namespace-http-www-springframework-org
여기에서는 spring-context라이브러리와 xsd 경로를 통일시키라고 하는데... 통일시켜도 동작하지 않는다.
=> 주요 해결책은 이것인것 같다. 거의 모든 구글 결과가 이 내용이다. 클래스패스에 라이브러리가 있는지 확인하고 해당 버전과 호환되는 버전을 써야 한다는 내용들이었다.

http://mojo.codehaus.org/exec-maven-plugin/exec-mojo.html
스프링 배치 샘플 프로젝트를 만들면 pom파일에 exec-maven-plugin이 있다. 이 플러그인을 통해서 mvn 명령어로 jar 파일을 실행 시킬 수 있다. 샘플 프로젝트의 폼 파일을 보면 아래와 같이 되어 있다.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
<arguments>
<!-- job configuration file -->
<argument>classpath:/launch-context.xml</argument>
<!-- job name -->
<argument>job1</argument>
</arguments>
</configuration>
</plugin>
launch-context.xml 파일에서 job1을 실행시키는 설정이 되어 있다.
이클립스에서 gaol에 exec:exec를 입력하고 실행시키면 된다.

참조:http://www.dashaun.com/2010/03/10/springframework-applicationcontext-woes-unable-to-locate-spring-namespacehandler/
http://stackoverflow.com/questions/15013651/using-maven-execexec-with-arguments
http://www.lucasward.net/2010/07/spring-batch-deployment-example.html

나에게 맞았던 해결책
출처: http://stackoverflow.com/questions/3335203/yet-another-unable-to-locate-spring-namespacehandler-error
Shade 플러그인을 쓰니까 해결이 되었다. - 아직 transformers 항목은 이해하지 못했다.
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.0</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/spring.handlers</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/spring.schemas</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <mainClass>org.XYZ</mainClass>
            </transformer>
          </transformers>
        </configuration>
      </execution>
    </executions>
  </plugin>

Maven - Packaging Jar With Dependency

http://stackoverflow.com/questions/1729054/including-dependencies-in-a-jar-with-maven

위의 링크에서 알려준 방법으로 만들 수 있었다.
추가로 나는 pom.xml 파일에 아래의 내용을 추가했다.
그리고 maven에서 mvn package 명령을 실행했다.
(이클립스에서 goal을 package로 설정 후 실행)

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
 <executions>
   <execution>
          <id>make-assembly</id> <!-- this is used for inheritance merges -->
          <phase>package</phase> <!-- bind to the packaging phase -->
     <goals>
          <goal>attached</goal>
     </goals>
   </execution>
 </executions>
 <configuration>
       <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
       </descriptorRefs>
   </configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>

참고:http://mkkbest.tistory.com/entry/11-1
http://valley.egloos.com/viewer/?url=http://entireboy.egloos.com/4615383

2013년 8월 2일 금요일

스프링 프레임워크 - 하둡

스프링에 하둡 배치 잡을 실행 시킬 수 있다.
참조: http://bcho.tistory.com/726
http://static.springsource.org/spring-hadoop/docs/current/reference/html/fs.html

환경 설정은 위의 참조 홈페이지를 따라 하면 되고 메이븐을 쓴다면
스프링 프레임워크의 하둡 프로젝트를 디펜던시에 추가해주면 된다.
디펜던지 참조: http://www.springsource.org/spring-data/hadoop

나는 설정을 이렇게 했다.
<hdp:configuration>
        fs.default.name=${hd.fs}
        dfs.name.dir=file://${name.dir}
        dfs.data.dir=file://${data.dir}
        hadoop.temp.dir=file://${temp.dir}
     </hdp:configuration>

그리고 나는 맵과 리듀스 그리고 드라이버 이렇게 하나의 하둡잡에 세개의 클래스를 만들었다.
그래서 스프링에서 아래와 같이 드라이버를 tool-runner로 실행했다.
<hdp:tool-runner id="내Driver" tool-class="com.내Driver"
run-at-startup="true">
    <hdp:arg value="/user/내hdfs/input"/>
    <hdp:arg value="/user/내hdfs/test/output"/>
    <hdp:arg value="세번째 인자"/>
    <hdp:arg value="네번째 인자"/>
    property=value
</hdp:tool-runner>

그리고 실행하니 NullPointerException이 난다.
Error creating bean with name 'adMainDriver': Invocation of init method failed; nested exception is java.lang.NullPointerExcepttion

원인은 잘 모르겠지만 결론적으론 내 하둡 설정이 잘못되어 있던 것인듯
스프링 소스에서 설정 부분을 아래로 바꿨더니 돌아간다.
파일 이름은 시스템에서 사용하는 하둡 설정 파일로 바꾸고 내 시스템의 하둡 설정 파일을 소스폴더에 붙여넣었다.
<hdp:configuration resources="classpath:/custom-site.xml, classpath:/hq-site.xml"/>

2013년 7월 31일 수요일

하둡과 스프링 연결 - 링크



한글 설명 조대협의 블로그: http://bcho.tistory.com/726
스프링 설정 방법 : http://static.springsource.org/spring-hadoop/docs/current/reference/html/hadoop.html
자바 맵 클래스 : http://levin01.tistory.com/233
자바 가변 인자 : http://omen666.tistory.com/229

cron 사용법 - 링크

Cent OS 6.4 - cron 사용법 : http://webdir.tistory.com/174
Redhat - cron 사용법 : http://majesty76.tistory.com/48
cron 시스템 이해와 사용 pdf 파일 : https://www.linux.co.kr/lecture/lec_linux_01/lec-data/10data.pdf

SimpleJdbcTemplate - SQL 파라미터

SimpleJdbcTemplate에 작업을 요청할 때는 문자열의 SQL을 제공해야 한다.
String 연산으로 SQL을 직접 만들었을 때 SQL 주입 공격 등에 노출 될 수 있다.
보통 Insert into table(colum1,col2) values(?,?); 와 같이 위치 치환자를 두고 파라미터를 바인딩한다.
또, SimpleJdbcTemplate은 이름을 통한 치환자 기능도 제공한다.
위의 SQL은 Intert into table (col1,col2) values (:name1,:name2); 와 같이 작성할 수 있다.
이름을 이용해 바인딩하기 때문에 중간에 순서가 바뀌어도 파라미터 바인딩에는 영향을 주지 않는다. 그리고 맵이나 오브젝트에 담긴 내용을 키 값이나 프로퍼티 이름을 이용해 바인딩 할 수 있다는 것이다.

출처: 토비의 스프링3, 이일민, 에이콘 http://www.acornpub.co.kr/book/toby-spring3

출처: http://forum.springsource.org/showthread.php?79470-Best-way-to-do-data-file-load-into-DB-table

클래스를 만들어서 jdbc에 접근하는 예제는 아래 참조를 보면 된다. 나는 위의 출처에서 xml 파일로 jdbc에 접근하는 예제를 사용했다.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:batch="http://www.springframework.org/schema/batch" 
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:util="http://www.springframework.org/schema/util"
 xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
  http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
  
 <batch:job id="fixedLengthFileDbDumpJob">
  <batch:step id="step1">
   <batch:tasklet>
    <batch:chunk reader="itemReader" writer="itemWriter" commit-interval="2"/>
   </batch:tasklet>
  </batch:step>
 </batch:job>
 <bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
  <property name="resource" value="file:/#{jobParameters[FILEPATH]}"/>
  <property name="lineMapper">
   <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
    <property name="lineTokenizer">
     <bean
      class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
      <property name="names" value="컬럼1,컬럼2,컬럼3, 컬럼4" />
      <property name="delimiter">
       <util:constant static-field="org.springframework.batch.item.file.transform.DelimitedLineTokenizer.DELIMITER_TAB"/>
     </bean>
    </property>
    <property name="fieldSetMapper">
     <bean
      class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
      <property name="targetType"
       value="my.custom.data.type" />
     </bean>
    </property>
   </bean>
  </property>
 </bean>

 <bean id="itemWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter">
  <property name="itemSqlParameterSourceProvider">
   <bean class="org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider" />
  </property>
  <property name="sql" value="insert into 테이블이름 (칼럼1이름, 칼럼2이름, 칼럼3이름, 칼럼4이름) values (:컬럼1,:컬럼2,:컬럼3, :컬럼4)" />                            
  <property name="assertUpdates" value="true"/>
   <property name="dataSource" ref="dataSource"/>
 </bean>

</beans>


참조: http://stackoverflow.com/questions/751400/how-to-xml-configure-spring-bean-for-constructor-injection-when-bean-has-varargs
http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapper.html
http://www.example8.com/category/view/id/452
http://www.java2s.com/Code/Java/Spring/SimpleJdbcInsertWithBeanPropertySqlParameterSource.htm
http://winmargo.tistory.com/118

Ubuntu Remote Desktop 사용

Windows나 Mac OS에서 우분투로 리모트 데스크톱을 사용할 수 있는 방법들이다.

먼저 우분투에서 Desktop sharing (혹은 remote desktop)을 검색해서 실행한다.
Allow other users to view your desktop 항목을 체크한다. (필요하면 그 아래 use 항목도 체크)
비밀번호 설정 후 닫는다.

기본적으로 vnc를 지원하기 때문에 따로 설정할 것은 없다. 기본포트(5900/5902)를 사용한다.

1. Mac에서 'Go' 선택 -> 'Connect Server' 선택 -> text line에 vnc://255.255.255.255  (IP주소)를 입력
    출처: http://superuser.com/questions/253044/remote-desktop-from-mac-to-ubuntu
2. ssh -X 사용
    출처: http://superuser.com/questions/573807/difficulty-to-enable-a-remote-desktop-connection-to-ubuntu-from-mac
3. tightVNC (Windows용) / Chicken of the VNC (Mac용) 사용
    출처: http://www.makeuseof.com/tag/ubuntu-remote-desktop-builtin-vnc-compatible-dead-easy/
4. Hard coding
    출처: http://mauroandres.wordpress.com/2013/01/14/enabling-the-remote-on-a-macbook-pro-running-ubuntu-12-10/

2013년 7월 30일 화요일

오늘의 지적사항

오늘의 지적사항


  1. 여러 번 반복적으로 사용되는 것은 상수로 지정하는 것이 효율적
  2. 스레드 1개에서만 사용 된다면 StringBuffer보다 StringBuilder가 효율적
  3. 리펙토링 - 코드 복잡도를 생각하자

Spring Batch my note- 스프링 배치 노트

Book : Pro Spring3  http://www.apress.com/java/spring/9781430241072
          It's source code http://www.apress.com/downloadable/download/sample/sample_id/1282/


Spring Batch version 1 은 item-oriented, version 2 는 chunk-oriented 이다.
그래서 version2 에서는 chunk size가 차면 reading/processing 한 것을 write step에 보낸다.

Spring Batch Infrastructure Components
1. JobRepository : Spring Batch metadata 하에서 Data 접근을 제공한다.
2. JobLauncher : 주어진 job과 parameter에 의거 job을 실행 한다.
3. JobOperator : version2에 새로 추가. job의 operation을 지원 - 실행중인 job 정지, 재시작 등
4. JobExplorer: version2에 새로 추가. Metadata에서 job 실행 정보를 확인 할 수 있다.

Spring Batch Infrastructure Configuration
Spring Batch에서 medatada 구조를 만들기 위한 DDL은 'spring-batch-core' module에 저장되어 있다. (org.springframework.batch.core 패키지에 있다)

참고
Spring Batch 관련 개념 및 예제 : http://ksug.org/61
Tutorial : http://keyholesoftware.com/2012/11/12/generating-large-excel-files-using-spring-batch-part-three/
Spring-JDBC : http://blog.outsider.ne.kr/882
Spring Concept : http://www.javajigi.net/pages/viewpage.action?pageId=5614
Job, Step, Tasklet, Flow : http://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte2:brte:batch_core:flow_control
                                         http://springsource.tistory.com/93
                                         http://static.springsource.org/spring-batch/reference/html/configureStep.html