OSCahce에 존재하지 않는 데이터를 반복적으로 호출하는 경우, 쓰레드 락이 걸려서 어플리케이션이 문제 될 수 있다.

 

List result = null;
try {
  result = (List) admin.getFromCache("aaa");
} catch (NeedsRefreshException e) {
  throw e;

}

 

OSCache GeneralCacheAdministrator 객체안에 Cache가 있고, updateStatus라는 object를 이용하여 key에 대한 wait를 하고, notify하는 구조로 되어 있다.

즉, get을 할 때는 wait() 콜을, set을 할 때는 notifyAll()로 구성되었다.

 

웹에서는 한꺼번에 리퀘스트가 몰려오거나, 리스타트시에 자주 발생될 수 있다.

현상은 CLOSE_WAIT가 많이 생기고 apache full이 일어나면서 L4에서 서버가 빠진다.

 

이 문제를 해결하기 위해서는 미리 oscache에 데이터를 미리 넣어두는 것이 최고다. 그게 어렵다면.. putIncache나 cancelupdate () 메소드를 호출해서 notifyAll() 시켜라~

 

List result = null;
try {
  result = (List) admin.getFromCache("aaa");
} catch (NeedsRefreshException e) {

  admin.cancelUpdate("aaa"); // 내부적으로 notifyAll()을 호출. wait하고 있는 객체를 깨움

 // 또는 admin.putInCache(...);

  throw e;

}

 

 

 

 

Posted by '김용환'
,

 

https://issues.apache.org/jira/browse/DBCP-270

 

common-pool 1.4와 common-dbcp 1.2.2 을 사용하면 데드락이 일어날 수 있다. 

 

common-dbcp 1.3에서 패치되었다.

 

Posted by '김용환'
,

DB 커넥션을 웹 서버마다 붙이면, DB는 커넥션 유지를 위해서 메모리와 해당 커넥션 관리를 해야 한다. 특히 자바의 특성상 connection pool을 써야 하기에 어쩌다 쓰는 쿼리를 위해서 써야만 했다.

이를 위해서 대충 조사를 해봤다.

 

sqlrelay나 c-jdbc를 테스트해보 쓸 수 있으면 써야 겠다.

 

 

 

상용 솔루션

-       BEA tuxedo : 이건 미들웨어형태로 제공합니다. UI/모니터링/로깅/자바/EJBAPI/로드밸런싱 지원합니다.

-       Tmaxsoft Tmax: 턱시도와 비슷

-       웹로직 – Multipools

-       나머지는 비주류 

Free 솔루션

-       Sqlrelay: http://sqlrelay.sourceforge.net/ - Linux GPL license

n  Database connection pooling을 지원하고, 프록싱과 로드밸런싱을 지원합니다.

n  장점 : 외국에서는 많이 사용되는 경우인 것으로 보임. 바로 사용 가능. 문서화 잘되어 있고, 웬만한 DB와 프로그래밍 언어 API를 지원합니다

n  단점 : UI 제공 없고, 재시작할 떄 오래 걸리고, 커넥션 문제시 해결을 위해서는 재시작해줘야 함 -> 시스템적으로 풀어야 하는 솔루션 ( + 나머지는 개발 필요),  

n  버전 : 0.40  (최신버젼이 나옴, 2009.1.8)

n  설명 잘된 한국어 웹 페이지 : http://kldp.org/node/45012

 

-        C-jdbc (http://c-jdbc.objectweb.org/) Apache LGPL license

n  Database connection pooling을 지원하고, 프록싱과 로드밸런싱을 지원하는 클러스터 DB 미들웨어.

n  장점 : JMX 기반의 모니터링과 어드민 지원,순수 자바로 개발. 문서화와 및 개발 커뮤니티가 제공됩니다. 트랙잰션/failover/로깅/모니터링 제공합니다.

n  단점 : 아직 모름.

n  버전 : 2.10.10 (2008.5.7)

n  설명 잘된 한국어 웹 페이지 : http://blog.empas.com/holyjohn/list.html?p=2

 

Posted by '김용환'
,

출처 : http://rationalsecurity.typepad.com/blog/edos/

 

DDOS 처럼 무작위 공격이 아닌 그냥 클라우딩 컴퓨팅을 제공하는 서버에 접속하여 사용자들이 서비스를 못하게 하는 방식이 EDOS이다.

아마존과 같은 클라우딩 컴퓨팅쪽으로 해커들이 공격한다라는 것이다..

 

 

Posted by '김용환'
,

 

 #!/bin/sh

# defines constant
default_timeout=5

timeout=$default_timeout
if [ -z $1 ]; then
    echo 'Usage: rsh.sh [-t timeout] command'
    echo ' ex) rsh.sh -t 5 a5555.google.com '
    echo ' ex) rsh.sh a5555.google.com '
    exit;
fi

param=$*
while getopts ":t:" opt; do
    case $opt in
        t ) timeout=$OPTARG;;
        \? ) echo "invalid option"
             exit;;
    esac
done

#$1->$0
shift $(($OPTIND - 1))

# background process
rsh "$@" &
backprocess=$!
sleep $timeout; kill -9 $backprocess; echo "time out $timeout seconds"
exit -1;

 

사용법


#!/usr/bin/perl
# rcmd(host, rcmd, lcmd)
sub rcmd {
  my $RSH = "/home/www/work/rsh.sh -t 1";
  chomp $RSH;
  my $RESULT = "";
  if($#_ == 1) {
     $RESULT = `$RSH $_[0] $_[1]`;
  } else {
    $RESULT = `$RSH $_[0] $_[1] | $_[2]`;
  }
  chomp $RESULT;
    return $RESULT;
}
rcmd("a55384", "ls -al");



 

 

Posted by '김용환'
,

rsh에는 timeout 기능이 없다. 있긴 한데.. 디폴트값으로 45초~1분사이의 값인 것 같다.

rsh을 쓰는 경우.. timeout이 걸릴때까지 시간이 소요되면, 동작이 잘 안될 수 있다.

 

겨우 찾은 샘플 소스..

백그라운드로 돌리고, 프로세스 id를 받아놓고, wait했다가 바로 kill 해주는 센스!!

 

 

 

http://groups.google.com/group/comp.unix.admin/msg/a0a2aefc71b7c631

 

 

 

 #!/bin/sh

timeout=$1
case $timeout in
[1-9]*) shift;;
*) timeout=10;;
esac

case $# in
0) echo 'Usage: timeoutrsh [timeout] cmd' >&2; exit;;
esac

rsh "$@" &
p=$!
(sleep $timeout; kill -1 $p) &
k=$!

wait $p
exit=$?
#  Normal exits are 0..127, signals are 128+signo
case $exit in
129)
        echo '(timed out)' >&2
        ;;
*)
        #  Kill the killer.
        kill $k
        ;;
esac
exit $exit

Posted by '김용환'
,

쿼리 스트링 ID를 가지고 특정 action(URL)로 보내되, 파라미터는 날린다.  (QSA 반대)

 

Rewritecond를 이용하여 query string을 비교하고,

RewriteRule의 Substitute 의 query string을 날릴 수 있다.

 

Rewritecond %{query_string} ^id=(.*)
RewriteRule   ^/google/flash.axs                    http://flash.google.com/%1?  [R,L]

 

 

Posted by '김용환'
,

    RewriteCond %{REQUEST_URI} !^/common/(.*)$
     RewriteRule ^.*$ http://www.google.com/gmail.php [R,L]

 

rewrite룰을 이렇게 사용하여 exclude 개념을 쓸 수 있다.

뒤에 더 나오는 RewriteRule의 영향을 받지 않기 하기 위해서, 꼭 L 옵션을 넣어주어야 한다.

Posted by '김용환'
,

자바스크립트 Dom 객체 생성하기

 

  var type = document.createElement("input");
  type.name = "type";
  type.value = document.underform.value;
  document.underform.appendChild(type);

 

 

 

 

<form method="post" action="/under/emergency.nhn" name="underform">
 <input type="hidden" name="m" value="update"/>
    <input type="hidden" name="underid" value="${under.underid}" />
    <input type="hidden" name="listUrl" value="${param.listUrl}"/>

'web' 카테고리의 다른 글

아파치 query string 붙이지 않고 날리기  (0) 2009.01.31
rewrite에서 exclude 사용하기  (0) 2009.01.30
인증서 문제  (0) 2008.12.15
Apache SSL 서버 만들기  (0) 2008.11.25
SQL Injection 공격에 따른 웹 어플 대응 (java)  (0) 2008.11.07
Posted by '김용환'
,

jsp 2.0 사용시 예제

java UI 2009. 1. 1. 04:18

http://pdf.coreservlets.com/JSP-EL.pdf

 

 

 

 <script language="javascript">

 function preview(form) {
  window.open("", "previewPopup", "width=800, height=600");
  form.m.value = "preview";
  form.target = "previewPopup";
  form.submit();
 }
 </script>   

 

 


 <c:forEach items="${list}" var="page" varStatus="status">
 <form method="post" action="/under/emergencyui.nhn" name="ui${status.index}">
    <tr>   
      <td>
       ID : <input name="id" value="${page.id}" size=1 disabled=true/>의  내용
      </td>
      <td>
       <textarea name="content" rows=15 cols=90><c:out value="${page.content}" escapeXml="true" /></textarea><br>
      </td>
      <td>
        <c:out value="${status.index}" />
   <input type="hidden" name="m" value="preview"/>
   <input type="button" value="미리보기" onclick="preview(ui${status.index})">
      <input type="button" value="저장" onclick="save()">
    </td>
    </tr>
    </form>
 </c:forEach>

 

 

'java UI' 카테고리의 다른 글

WindowBuilder Pro  (0) 2011.09.01
quartz 를 이용하기  (0) 2008.01.22
File Connection Optiobal Package  (0) 2006.02.28
[펌] DataSource의 복제를 통한 다중 플레이어 생성방법  (0) 2005.12.02
jtable tutorial  (0) 2005.02.16
Posted by '김용환'
,