Tuesday 21 February 2017

[Lua] Basic Functions

Basic Functions (ver.5.1)

https://www.lua.org/manual/5.1/manual.html

assert (v [, message])

Issues an error when the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. message is an error message; when absent, it defaults to "assertion failed!"

collectgarbage ([opt [, arg]])

This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt:

"collect": performs a full garbage-collection cycle. This is the default option.
"stop": stops the garbage collector.
"restart": restarts the garbage collector.
"count": returns the total memory in use by Lua (in Kbytes).
"step": performs a garbage-collection step. The step "size" is controlled by arg (larger values mean more steps) in a non-specified way. If you want to control the step size you must experimentally tune the value of arg. Returns true if the step finished a collection cycle.
"setpause": sets arg as the new value for the pause of the collector (see §2.10). Returns the previous value for pause.
"setstepmul": sets arg as the new value for the step multiplier of the collector (see §2.10). Returns the previous value for step.

dofile ([filename])

Opens the named file and executes its contents as a Lua chunk. When called without arguments, dofile executes the contents of the standard input (stdin). Returns all values returned by the chunk. In case of errors, dofile propagates the error to its caller (that is, dofile does not run in protected mode).

error (message [, level])

Terminates the last protected function called and returns message as the error message. Function error never returns.
Usually, error adds some information about the error position at the beginning of the message. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.

_G

A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.)

getfenv ([f])

Returns the current environment in use by the function. f can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling getfenv. If the given function is not a Lua function, or if f is 0, getfenv returns the global environment. The default for f is 1.

getmetatable (object)

If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a "__metatable" field, returns the associated value. Otherwise, returns the metatable of the given object.

ipairs (t)

Returns three values: an iterator function, the table t, and 0, so that the construction

for i,v in ipairs(t) do body end
will iterate over the pairs (1,t[1]), (2,t[2]), ···, up to the first integer key absent from the table.

load (func [, chunkname])

Loads a chunk using function func to get its pieces. Each call to func must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk.
If there are no errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message. The environment of the returned function is the global environment.
chunkname is used as the chunk name for error messages and debug information. When absent, it defaults to "=(load)".

loadfile ([filename])

Similar to load, but gets the chunk from file filename or from the standard input, if no file name is given.

loadstring (string [, chunkname])

Similar to load, but gets the chunk from the given string.
To load and run a given string, use the idiom

assert(loadstring(s))()

When absent, chunkname defaults to the given string.

next (table [, index])

Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. next returns the next index of the table and its associated value. When called with nil as its second argument, next returns an initial index and its associated value. When called with the last index, or with nil in an empty table, next returns nil. If the second argument is absent, then it is interpreted as nil. In particular, you can use next(t) to check whether a table is empty.
The order in which the indices are enumerated is not specified, even for numeric indices. (To traverse a table in numeric order, use a numerical for or the ipairs function.)
The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields.

pairs (t)

Returns three values: the next function, the table t, and nil, so that the construction

for k,v in pairs(t) do body end
will iterate over all key?value pairs of table t.
See function next for the caveats of modifying the table during its traversal.


pcall (f, arg1, ···)

Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.

print (···)

Receives any number of arguments, and prints their values to stdout, using the tostring function to convert them to strings. print is not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format.

rawequal (v1, v2)

Checks whether v1 is equal to v2, without invoking any metamethod. Returns a boolean.

rawget (table, index)

Gets the real value of table[index], without invoking any metamethod. table must be a table; index may be any value.

rawset (table, index, value)

Sets the real value of table[index] to value, without invoking any metamethod. table must be a table, index any value different from nil, and value any Lua value.
This function returns table.

select (index, ···)

If index is a number, returns all arguments after argument number index. Otherwise, index must be the string "#", and select returns the total number of extra arguments it received.

setfenv (f, table)

Sets the environment to be used by the given function. f can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling setfenv. setfenv returns the given function.
As a special case, when f is 0 setfenv changes the environment of the running thread. In this case, setfenv returns no values.

setmetatable (table, metatable)

Sets the metatable for the given table. (You cannot change the metatable of other types from Lua, only from C.) If metatable is nil, removes the metatable of the given table. If the original metatable has a "__metatable" field, raises an error.
This function returns table.

tonumber (e [, base])

Tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then tonumber returns this number; otherwise, it returns nil.
An optional argument specifies the base to interpret the numeral. The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter 'A' (in either upper or lower case) represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. In base 10 (the default), the number can have a decimal part, as well as an optional exponent part (see §2.1). In other bases, only unsigned integers are accepted.

tostring (e)

Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format.
If the metatable of e has a "__tostring" field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result.

type (v)

Returns the type of its only argument, coded as a string. The possible results of this function are "nil" (a string, not the value nil), "number", "string", "boolean", "table", "function", "thread", and "userdata".

unpack (list [, i [, j]])

Returns the elements from the given table. This function is equivalent to
return list[i], list[i+1], ···, list[j]
except that the above code can be written only for a fixed number of elements. By default, i is 1 and j is the length of the list, as defined by the length operator (see §2.5.5).

_VERSION

A global variable (not a function) that holds a string containing the current interpreter version. The current contents of this variable is "Lua 5.1".

xpcall (f, err)

This function is similar to pcall, except that you can set a new error handler.
xpcall calls function f in protected mode, using err as the error handler. Any error inside f is not propagated; instead, xpcall catches the error, calls the err function with the original error object, and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In this case, xpcall also returns all results from the call, after this first result. In case of any error, xpcall returns false plus the result from err.

Monday 20 February 2017

[Eclipse] C/C++ development environment in eclipse using CDT (Eclipse C/C++ 개발 환경)

1. Install CDT plugin

Help -> Install New Software





Add Repository -> http://download.eclipse.org/tools/cdt/releases/[REALEASE_VERSION]




Check and install plugins




2. Install MinGW

Intall MinGW or cygwin

Download MinGW -> https://sourceforge.net/projects/mingw/files/Installer/




Execute Installer





3. Setup Envionment Variable

Add %MinGW_HOME%/bin in $PATH%





 

 

 

 

 

 

 

 

4. Create C Project

New Project -> C/C++ -> C Project







































5. Create C Source File and Compile






[VisualStudio] ErrorCode-C1853 미리 컴파일된 헤더 파일이 이전 버전의 컴파일러에서 만들어졌거나, 미리 컴파일된 헤더가 C++인데 C에서 사용하고 있거나 또는 그 반대의 경우입니다.


<Compile Error>





< Solution>

1. Menu Bar Project(프로젝트) -> Project Properties(속성)





2. C/C++ -> 미리 컴파일된 헤더 -> 미리 컴파일된 헤더 설정 '미리 컴파일된 헤더 사용 안 함'

Thursday 16 February 2017

[Redis] Scan in Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package test.redis;

import java.util.List;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.ScanResult;

/*
 * ************************************************************************************
 *
 * RedisScanTest.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2017-02-10 dorbae Initialize
 * @since 2017-02-10
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class RedisScanTest {

 public RedisScanTest() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  Jedis jedis = new Jedis("btcxen.esb.broker1");
  System.out.println("Connection to server sucessfully");

  ScanResult< String> rs = jedis.scan( "0");
  List< String> list = rs.getResult();
  
  for ( int ll = 0; ll<list.size(); ll++) { 
          System.out.println("List of stored keys:: "+list.get(ll)); 
      }
  
  jedis.close();
  
 }

}

[Redis] Hash in Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package test.redis;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import redis.clients.jedis.Jedis;

/*
 * ************************************************************************************
 *
 * RedisHashTest.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2017-02-10 dorbae Initialize
 * @since 2017-02-10
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class RedisHashTest {

 public RedisHashTest() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  Jedis jedis = new Jedis( "btcxen.esb.broker1");
  System.out.println( "Connection to server sucessfully");

  
  jedis.hset( "hs1", "col1", "val1");
  jedis.hset( "hs1", "col2", "val2");
  jedis.hset( "hs1", "col3", "val3");
  jedis.hset( "hs1", "col4", "val4");
  
  java.util.Map< String, String> map = new java.util.HashMap< String, String>();
  map.put( "col1", "mval1");
  map.put( "col2", "mval2");
  map.put( "col3", "mval3");
  
  jedis.hmset( "hs1", map);
  
  jedis.hdel( "hs1", "col2", "col3");
  
  
  System.out.println( "len=" + jedis.hlen( "hs1"));

  System.out.println( "hs1.col2="+ jedis.hget( "hs1", "col2"));
  
  map = jedis.hgetAll( "hs1");
  Iterator< Entry< String, String>> iterator = map.entrySet().iterator();
  
  Entry< String, String> entry = null;
  while ( iterator.hasNext()) {
   entry = iterator.next();
   System.out.printf( "key:%s, value:%s%n", entry.getKey(), entry.getValue());
   
  }
  
  jedis.close();
  
 }

}

[Redis] List in Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package test.redis;

import java.util.List;

import redis.clients.jedis.Jedis;

/*
 * ************************************************************************************
 *
 * RedisListTest.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2017-02-10 dorbae Initialize
 * @since 2017-02-10
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class RedisListTest {

 public RedisListTest() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  //Connecting to Redis server on localhost 
       Jedis jedis = new Jedis("btcxen.esb.broker1"); 
       System.out.println("Connection to server sucessfully"); 
       
       //store data in redis list 
       jedis.lpush("tutorial-list", "Redis"); 
       jedis.lpush("tutorial-list", "Mongodb"); 
       jedis.lpush("tutorial-list", "Mysql"); 
       // Get the stored data and print it 
//       List<String> list = jedis.lrange("tutorial-list", 0 ,1); 
       List<String> list = jedis.lrange("tutorial-list", 0 ,6); 
       
       for(int i = 0; i<list.size(); i++) { 
          System.out.println("Stored string in redis:: "+list.get(i)); 
       }
       
       jedis.close();

 }

}

[Redis] Set in Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package test.redis;

import redis.clients.jedis.Jedis;

/*
 * ************************************************************************************
 *
 * RedisSetTest.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2017-02-10 dorbae Initialize
 * @since 2017-02-10
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class RedisSetTest {

 public RedisSetTest() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  Jedis jedis = new Jedis( "btcxen.esb.broker1");
  System.out.println( "Connection to server sucessfully");

  
  jedis.sadd( "set1", "1", "2", "3", "3", "4");
  System.out.println( "Set size=" + jedis.scard( "set1"));
  

  jedis.close();

 }

}

[Redis] Set/Get Key//Value in Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package test.redis;

import redis.clients.jedis.Jedis;

/*
 * ************************************************************************************
 *
 * RedisStringTest.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2017-02-10 dorbae Initialize
 * @since 2017-02-10
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class RedisStringTest {

 public RedisStringTest() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  //Connecting to Redis server on localhost 
       Jedis jedis = new Jedis("btcxen.esb.broker1"); 
       System.out.println("Connection to server sucessfully"); 
       //set the data in redis string 
       jedis.set("tutorial-name", "Redis tutorial"); 
       // Get the stored data and print it 
       System.out.println("Stored string in redis:: "+ jedis.get("tutorial-name"));

 }

}

[Redis] Connect Redis Server in Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package test.redis;

import redis.clients.jedis.Jedis;

/*
 * ************************************************************************************
 *
 * ConnectRedisServerTest.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2017-02-10 dorbae Initialize
 * @since 2017-02-10
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class ConnectRedisServerTest {

 public ConnectRedisServerTest() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  //Connecting to Redis server on localhost 
       Jedis jedis = new Jedis( "btcxen.esb.broker1", 6379); 
       System.out.println("Connection to server sucessfully"); 
       //check whether server is running or not 
       System.out.println("Server is running: "+jedis.ping());

 }

}




Wednesday 15 February 2017

[PuTTY] How to fix window title

1. Windows -> Behaviour -> Window title



2. Terminal -> Features -> Check 'Disable remote-controlled window title changing







Tuesday 14 February 2017

[Javadoc] Javadoc option

usage: javadoc [options] [packagenames] [sourcefiles] [@files]

-overview Read overview documentation from HTML file
-public Show only public classes and members
-protected Show protected/public classes and members (default)
-package Show package/protected/public classes and members
-private Show all classes and members
-help Display command line options and exit
-doclet Generate output via alternate doclet
-docletpath Specify where to find doclet class files
-sourcepath Specify where to find source files
-classpath Specify where to find user class files
-exclude Specify a list of packages to exclude
-subpackages Specify subpackages to recursively load
-breakiterator Compute 1st sentence with BreakIterator
-bootclasspath Override location of class files loaded
by the bootstrap class loader
-source Provide source compatibility with specified release
-extdirs Override location of installed extensions
-verbose Output messages about what Javadoc is doing
-locale Locale to be used, e.g. en_US or en_US_WIN
-encoding Source file encoding name
-quiet Do not display status messages
-J Pass directly to the runtime system
-X Print a synopsis of nonstandard options


Provided by Standard doclet

-d Destination directory for output files
-use Create class and package usage pages
-version Include @version paragraphs
-author Include @author paragraphs
-docfilessubdirs Recursively copy doc-file subdirectories
-splitindex Split index into one file per letter
-windowtitle Browser window title for the documenation
-doctitle Include title for the overview page
-header Include header text for each page
-footer Include footer text for each page
-top Include top text for each page
-bottom Include bottom text for each page
-link Create links to javadoc output at
-linkoffline Link to docs at using package list at
-excludedocfilessubdir :.. Exclude any doc-files subdirectories with given name.
-group :.. Group specified packages together in overview page
-nocomment Supress description and tags, generate only declarations.
-nodeprecated Do not include @deprecated information
-noqualifier ::... Exclude the list of qualifiers from the output.
-nosince Do not include @since information
-notimestamp Do not include hidden time stamp
-nodeprecatedlist Do not generate deprecated list
-notree Do not generate class hierarchy
-noindex Do not generate index
-nohelp Do not generate help link
-nonavbar Do not generate navigation bar
-serialwarn Generate warning about @serial tag
-tag ::
Specify single argument custom tags
-taglet The fully qualified name of Taglet to register
-tagletpath The path to Taglets
-Xdocrootparent Replaces all appearances of @docRoot followed by /.. in doc comments with
-charset Charset for cross-platform viewing of generated documentation.
-helpfile Include file that help link links to
-linksource Generate source in HTML
-sourcetab Specify the number of spaces each tab takes up in the source
-keywords Include HTML meta tags with package, class and member info
-stylesheetfile File to change style of the generated documentation
-docencoding Output encoding name

Friday 10 February 2017

[Redis] How to set server to connect from remote client




1. Modify configuration

#> vi /etc/redis.conf





bind 127.0.0.1 -> bind 0.0.0.0 or bind [allowed host]




2. Restart server

# CentOS 6
#> service redis restart

# CentOS 7
#> systemctl restart redis

[Redis] Install Redis

1. Install packages

in CentOS 6

1
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

1
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm






in CenstOS 7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm



2. Install Redis

#> yum -y --enablerepo=epel,remi install redis





3. Startup Redis

# CentOS 6
#> service redis restart

# CentOS 7
#> systemctl restart redis





4. Register boot process

# CentOS 6
#> chkconfig redis on

# CentOS 7
#> systemctl enable redis.service

[HTTP] Status Code List

https://ko.wikipedia.org/wiki/HTTP_%EC%83%81%ED%83%9C_%EC%BD%94%EB%93%9C 참조

1xx (조건부 응답)

요청을 받았으며 작업을 계속한다.

100 계속 요청자는 요청을 계속해야 한다. 서버는 이 코드를 제공하여 요청의 첫 번째 부분을 받았으며 나머지를 기다리고 있음을 나타낸다.
101 프로토콜 전환 요청자가 서버에 프로토콜 전환을 요청했으며 서버는 이를 승인하는 중이다.
102 처리 RFC 2518

2xx (성공)

이 클래스의 상태 코드는 클라이언트가 요청한 동작을 수신하여 이해했고 승낙했으며 성공적으로 처리했음을 가리킨다.

200 성공 서버가 요청을 제대로 처리했다는 뜻이다. 이는 주로 서버가 요청한 페이지를 제공했다는 의미로 쓰인다.
201 작성됨 성공적으로 요청되었으며 서버가 새 리소스를 작성했다.
202 허용됨 서버가 요청을 접수했지만 아직 처리하지 않았다.
203 신뢰할 수 없는 정보 서버가 요청을 성공적으로 처리했지만 다른 소스에서 수신된 정보를 제공하고 있다.
204 콘텐츠 없음 서버가 요청을 성공적으로 처리했지만 콘텐츠를 제공하지 않는다.
205 콘텐츠 재설정 서버가 요청을 성공적으로 처리했지만 콘텐츠를 표시하지 않는다. 204 응답과 달리 이 응답은 요청자가 문서 보기를 재설정할 것을 요구한다(예: 새 입력을 위한 양식 비우기).
206 일부 콘텐츠 서버가 GET 요청의 일부만 성공적으로 처리했다.
207 다중 상태 RFC 4918
208 이미 보고됨 RFC 5842
226 IM Used RFC 3229


3xx (리다이렉션 완료)

클라이언트는 요청을 마치기 위해 추가 동작을 취해야 한다.


300여러 선택항목서버가 요청에 따라 여러 조치를 선택할 수 있다. 서버가 사용자 에이전트에 따라 수행할 작업을 선택하거나, 요청자가 선택할 수 있는 작업 목록을 제공한다.
301영구 이동요청한 페이지를 새 위치로 영구적으로 이동했다. GET 또는 HEAD 요청에 대한 응답으로 이 응답을 표시하면 요청자가 자동으로 새 위치로 전달된다.
302임시 이동현재 서버가 다른 위치의 페이지로 요청에 응답하고 있지만 요청자는 향후 요청 시 원래 위치를 계속 사용해야 한다.
303기타 위치 보기요청자가 다른 위치에 별도의 GET 요청을 하여 응답을 검색할 경우 서버는 이 코드를 표시한다. HEAD 요청 이외의 모든 요청을 다른 위치로 자동으로 전달한다.
304수정되지 않음마지막 요청 이후 요청한 페이지는 수정되지 않았다. 서버가 이 응답을 표시하면 페이지의 콘텐츠를 표시하지 않는다. 요청자가 마지막으로 페이지를 요청한 후 페이지가 변경되지 않으면 이 응답(If-Modified-Since HTTP 헤더라고 함)을 표시하도록 서버를 구성해야 한다.
305프록시 사용요청자는 프록시를 사용하여 요청한 페이지만 액세스할 수 있다. 서버가 이 응답을 표시하면 요청자가 사용할 프록시를 가리키는 것이기도 하다.
307임시 리다이렉션현재 서버가 다른 위치의 페이지로 요청에 응답하고 있지만 요청자는 향후 요청 시 원래 위치를 계속 사용해야 한다.
308영구 리다이렉션RFC에서 실험적으로 승인됨.


4xx (요청 오류)

4xx 클래스의 상태 코드는 클라이언트에 오류가 있음을 나타낸다.

400잘못된 요청서버가 요청의 구문을 인식하지 못했다.
401권한 없음이 요청은 인증이 필요하다. 서버는 로그인이 필요한 페이지에 대해 이 요청을 제공할 수 있다.
402결제 필요이 요청은 결제가 필요합니다.
403금지됨서버가 요청을 거부하고 있다.
404찾을 수 없음서버가 요청한 페이지를 찾을 수 없다. 예를 들어 서버에 존재하지 않는 페이지에 대한 요청이 있을 경우 서버는 이 코드를 제공한다.
405허용되지 않는 방법요청에 지정된 방법을 사용할 수 없다.
406허용되지 않음요청한 페이지가 요청한 콘텐츠 특성으로 응답할 수 없다.
407프록시 인증 필요이 상태 코드는 401(권한 없음)과 비슷하지만 요청자가 프록시를 사용하여 인증해야 한다. 서버가 이 응답을 표시하면 요청자가 사용할 프록시를 가리키는 것이기도 한다.
408요청 시간초과서버의 요청 대기가 시간을 초과하였다.
409충돌서버가 요청을 수행하는 중에 충돌이 발생했다. 서버는 응답할 때 충돌에 대한 정보를 포함해야 한다. 서버는 PUT 요청과 충돌하는 PUT 요청에 대한 응답으로 이 코드를 요청 간 차이점 목록과 함께 표시해야 한다.
410사라짐서버는 요청한 리소스가 영구적으로 삭제되었을 때 이 응답을 표시한다. 404(찾을 수 없음) 코드와 비슷하며 이전에 있었지만 더 이상 존재하지 않는 리소스에 대해 404 대신 사용하기도 한다. 리소스가 영구적으로 이동된 경우 301을 사용하여 리소스의 새 위치를 지정해야 한다.
411길이 필요서버는 유효한 콘텐츠 길이 헤더 입력란 없이는 요청을 수락하지 않는다.
412사전조건 실패서버가 요청자가 요청 시 부과한 사전조건을 만족하지 않는다.
413요청 속성이 너무 큼요청이 너무 커서 서버가 처리할 수 없다.
414요청 URI가 너무 긺요청 URI(일반적으로 URL)가 너무 길어 서버가 처리할 수 없다.
415지원되지 않는 미디어 유형요청이 요청한 페이지에서 지원하지 않는 형식으로 되어 있다.
416처리할 수 없는 요청범위요청이 페이지에서 처리할 수 없는 범위에 해당되는 경우 서버는 이 상태 코드를 표시한다.
417예상 실패서버는 Expect 요청 헤더 입력란의 요구사항을 만족할 수 없다.
418I'm a teapotRFC 2324
420Enhance Your Calm트위터
422처리할 수 없는 엔티티WebDAV; RFC 4918
423잠김WebDAV; RFC 4918
424실패된 의존성, WebDAV; RFC 4918)
424메쏘드 실패WebDAV
425정렬되지 않은 컬렉션인터넷 초안
426업그레이드 필요RFC 2817
428전제조건 필요RFC 6585
429너무 많은 요청RFC 6585
431요청 헤더 필드가 너무 큼RFC 6585
444응답 없음Nginx
449다시 시도마이크로소프트
450윈도 자녀 보호에 의해 차단됨마이크로소프트
451법적인 이유로 이용 불가인터넷 초안
451리다이렉션마이크로소프트
494요청 헤더가 너무 큼Nginx
495Cert 오류Nginx
496Cert 없음Nginx
497HTTP to HTTPSNginx
499클라이언트가 요청을 닫음Nginx



5xx (서버 오류)

서버가 유효한 요청을 명백하게 수행하지 못했음을 나타낸다.

Apache bw/limited extension
500내부 서버 오류서버에 오류가 발생하여 요청을 수행할 수 없다.
501구현되지 않음서버에 요청을 수행할 수 있는 기능이 없다. 예를 들어 서버가 요청 메소드를 인식하지 못할 때 이 코드를 표시한다.
502불량 게이트웨이서버가 게이트웨이나 프록시 역할을 하고 있거나 또는 업스트림 서버에서 잘못된 응답을 받았다.
503서비스를 사용할 수 없음서버가 오버로드되었거나 유지관리를 위해 다운되었기 때문에 현재 서버를 사용할 수 없다. 이는 대개 일시적인 상태이다.
504게이트웨이 시간초과서버가 게이트웨이나 프록시 역할을 하고 있거나 또는 업스트림 서버에서 제때 요청을 받지 못했다.
505HTTP 버전이 지원되지 않음서버가 요청에 사용된 HTTP 프로토콜 버전을 지원하지 않는다.
506Variant Also NegotiatesRFC 2295
507용량 부족WebDAV; RFC 4918
508루프 감지됨WebDAV; RFC 5842
509대역폭 제한 초과
510확장되지 않음RFC 2774
511네트워크 인증 필요RFC 6585
598네트워크 읽기 시간초과 오류알 수 없음
599네트워크 연결 시간초과 오류알 수 없음

Thursday 9 February 2017

[Temp] REST 이론

- 자바 플랫폼은 JSR-311 표준에 따름(JAX-RS The Java API for RESTfull Web SErvices)
- Spring Web MVCㄴ은 JSR-311을 따르지는 않음
- 2000년도에

[JSON] JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object

<Pre Object Constructure>

1
2
3
4
5
        public DHT22Data( Integer mcuId, Long sensorDt) {
  this.mcuId = mcuId;
  this.sensorDt = sensorDt;
  
 }


<New Object Constructure>


1
2
3
4
5
         public DHT22Data( @JsonProperty( "id") Integer mcuId, @JsonProperty("sendt") Long sensorDt) {
  this.mcuId = mcuId;
  this.sensorDt = sensorDt;
  
 }

[Log4j] Logging Pattern (로그 패턴)

Pattern Description Example
%p Logging Level (DEBUG, INFO,...) %-5p
%m Log Message
%d Logging Timestamp. It can use date format obeying a SimpleDateFormat rules.
Default. yyyy-MM-dd HH:mm:ss
%d{yyyy MMM dd HH:mm:ss, SSS}%d{HH:mm:ss, SSS}
%d{ISO8601}
%d{ABSOLUTE}
%d{DATE}
%d{UNIX_MILLIS}
%t Thread Name
%T Thread ID
%n New Line. It is dependent on OS platform.
Unix/Linux : LF
Windows : CR-LF
MacOS : CR
%c Category %c{n}
%C Class name. It display class full name including package name and cut package name off
ex) pe.dorbae.blog.Log4j
%C{1} : Log4j
%C{3} dorbae.blog.Log4j

%C{n}
%F File Name
%l Location information of the caller which generated the logging event
%L Caller Line Number
%M Method Name
%r Uptime (milliseconds)
%x Thread NDC(Nested Diagnostic Context)
%X Thread MDC(Mapped Diagnostic Context)
%u Random or a time-based UUID %u{RANDOM}
%u{TIME}

Wednesday 1 February 2017

[Log4j] Set logging level particular package (특정 패키지 로깅레벨 설정)

log4j.logger.{name.of.the.package}=DEBUG, console
log4j.logger.{name.of.the.package}=INFO, logfile


[Shellscript] Kill all processes filtered using grep

1
2
3
4
5
6
7
8
#!/bin/sh

# Kill Process
echo "Kill process..."
ps -ef | grep ... | grep ... | awk '{print $2}' | while read line; do kill $line; done
echo "Finished to kill process."

exit 0

[Maria/MySQL] ost 'x.x.x.x' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

I can't connect MariaDB in particular server using JDBC driver. When I try to connect db, error message than says "ost 'x.x.x.x' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'" occurs.




It is related with database configuration. (max_connect_errors)

If a particular host make too many connect errors that exceeds allowed max_connect_errors count, database server consider this connection as hacking or inavlid connection. So, the server prevent connections from that host.


[Solution]

1. Initialize count

#> mysqladmin -uroot -p flush-hosts


2. Change max connect errors count

- in running


#> mysql -uroot -p




SET GLOBAL max_connect_errors=[COUNT];




- modify configuration file

#> vi /etc/my.conf

[CentOS7] NTP 서버 설정

* NTP : Network Time Protocol


1. Install NTP package

#> yum -y install ntp




2. Configure NTP environment

#> vi /etc/ntp.conf






3. Startup NTP daemon and register system start process daemon

# below CentOS 7
#> service ntpd start
#> chkconfig ntpd on

# in CentOS 7
#> systemctl start ntpd
#> systemctl enable ntpd




4. Check process

#> ntpq -p