com.nhncorp.neptune.master
Class NeptuneMaster

java.lang.Object
  extended by com.nhncorp.neptune.master.NeptuneMaster
All Implemented Interfaces:
ProxyObject, AsyncCallProtocol, Constants, NVersionedProtocol, NeptuneMasterIF, TableManagerProtocol, TabletMasterProtocol, java.lang.Runnable

public class NeptuneMaster
extends java.lang.Object
implements NeptuneMasterIF

Neptune의 클러스터를 관리하는 Master

NeptuneMaster의 역할은 Tablet을 할당해주는 역할만 수행한다. 따라서 NeptuneMaster에 장애가 발생해도 데이터 서비스(get, put)은 정상 서비스 가능하다.

Author:
김형준

Field Summary
static org.apache.commons.logging.Log LOG
           
static NeptuneMaster neptuneMaster
           
 
Fields inherited from interface com.nhncorp.neptune.master.TableManagerProtocol
versionID
 
Fields inherited from interface com.nhncorp.neptune.master.TabletMasterProtocol
versionID
 
Fields inherited from interface com.nhncorp.neptune.common.Constants
BATCH_RECEIVER_SUCCESS, BATCH_UPLOAD, CHANGELOG_SERVER, COMPACTION, DELETEED, END_RECEIVE_ROW, GROUPS, INDEX_INTERVAL_LENGH, INSERTED, LOG_OP_ADD_COLUMN_VALUE, LOG_OP_CREATE_ROW, LOG_OP_DELETE_COLUMN_VALUE, LOG_OP_MODIFY_META, MAP_RECORD_COLUMN, MAP_RECORD_ROW, MASTER, MASTER_SERVER, MAX_KEY_LENGTH, MAX_VALUE, META_COLUMN_NAME_TABLETINFO, MIN_VALUE, NEPTUNE, OPEN_SCANNER, PATH_SCHEMA, PIPE_CL_FILE_NAME, PROCESS, ROOT_TABLET, SCANNER_END, SCANNER_OPEN_FAIL, SCANNER_OPEN_SUCCESS, SCHEMA_DESCRIPTION_FILE_NAME, SCHEMA_INFO_FILENAME, SERVER, SPLIT, SPLIT_INFO, SPLIT_STORE, SUPERGROUP, TABLE_DROP, TABLE_LOCK, TABLE_NAME_META, TABLE_NAME_ROOT, TABLET_ALIVE, TABLET_ASSIGN, TABLET_AVAIL, TABLET_CREATED, TABLET_DROP, TABLET_FAIL, TABLET_STOP_MARK, TABLETSERVER_SPLIT, TEST_MODE, UPLOAD_END, UPLOAD_FAIL, UPLOAD_START_ROW, UPLOADER, USERS
 
Constructor Summary
NeptuneMaster()
           
 
Method Summary
 void addColumn(java.lang.String tableName, java.lang.String addedColumnName)
          테이블에 컬럼을 추가한다.
 void addTablePermission(java.lang.String tableName, java.lang.String userId, java.lang.String readWrite)
           
 TabletInfo addTablet(java.lang.String tableName, Row.Key endRowKey)
          테이블에 새로운 Tablet을 추가한다.
 void addUser(java.lang.String userId)
           
 boolean assignTablet(TabletInfo tabletInfo)
          Tablet을 tablet server에 할당한다. ignoreFlag는 tablet이 현재 다른 tabletserver에 의해 로딩중이거나 서비스중에 상관없이 지정된 tablet server로 할당된다.
 boolean checkServer()
           
 void createTable(TableSchema table, Row.Key[] endRowKeys)
          테이블을 생성한다. endRowKeys에 초기에 생성할 tablet에 대한 목록이 있는 경우 tablet을 여러개 생성시키고 그렇지 않는 경우 min ~ max 범위를 저장하는 하나의 tablet만 생성한다.
static boolean doFormat(NConfiguration conf)
          모든 데이터 및 스키마를 삭제한다.
 java.lang.String dropTable(java.lang.String tableName)
          테이블을 drop한다.
 void endTableDrop(java.lang.String taskId, java.lang.String hostName, java.lang.String tableName)
           
 void endTabletAssignment(TabletInfo tabletInfo, boolean created)
           
 void endTabletAssignmentForHandler(TabletInfo tabletInfo, boolean created)
          Proxy를 이용해서 테스트 코드를 작성하기 위해 인터페이스로 빼서 처리, 실제는 endTabletAssignment 처리
 void errorTableDrop(java.lang.String taskId, java.lang.String hostName, java.lang.String tableName, java.lang.String message)
           
 void errorTabletAssignment(java.lang.String hostName, TabletInfo tabletInfo)
          Tablet할당 에러 발생시 다음과 같이 처리한다. 1.
static java.lang.String finalizeDrop(NeptuneMaster neptuneMaster, NConfiguration conf, NeptuneFileSystem fs, com.nhncorp.pleiades.client.LockService lockService, java.lang.String tableName, boolean forced)
           
static void forcedDropTable(java.lang.String tableName)
          lock, schema 존재여부 상관없이 drop 처리
static void format()
          모든 데이터 및 스키마를 삭제한다.
static void formatFileSystem(NConfiguration conf)
           
 AsyncTaskStatus getAsyncTaskStatus(java.lang.String taskId)
           
 NConfiguration getConf()
           
 java.lang.String getHostName()
           
static java.lang.String getMasterServerHostName(com.nhncorp.pleiades.client.LockService lockService)
          master가 실행되고 있는 서버 정보를 반환한다.
 long getProtocolVersion(java.lang.String protocol, long clientVersion)
          Return protocol version corresponding to protocol interface.
 TabletInfo[] getTablets(java.lang.String tableName)
          특정 테이블의 Tablet 목록을 조회한다.
 TabletServerInfo[] getTabletServerInfos()
           
 java.lang.String getTestHandlerKey()
           
 void init(NeptuneMasterIF proxyObject, NConfiguration conf)
           
static boolean isClusterReady()
          ROOT, META가 모두 로딩된 상태
 boolean isShutdowned()
           
 TableSchema[] listTables()
          테이블 목록을 조회한다.
static void main(java.lang.String[] args)
           
 void removeAsyncTask(java.lang.String taskId)
           
 void removeTablePermission(java.lang.String tableName, java.lang.String userId)
           
 void removeUser(java.lang.String userId)
           
 void reportTabletServerStarted(java.lang.String hostName)
          네트워크 설정 문제로 Pleiades event handler를 사용하지 못할 경우 TabletServer가 NeptuneMaster로 live 상태를 전송한다.
 void reportTabletSplited(TabletInfo targetTablet, TabletInfo[] splitedTablets)
           
 void run()
          NeptuneMaster main thread
 void shutdown()
           
 void test()
           
 boolean tryMasterLock()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

neptuneMaster

public static NeptuneMaster neptuneMaster
Constructor Detail

NeptuneMaster

public NeptuneMaster()
Method Detail

init

public void init(NeptuneMasterIF proxyObject,
                 NConfiguration conf)
          throws java.io.IOException
Specified by:
init in interface NeptuneMasterIF
Throws:
java.io.IOException

run

public void run()
NeptuneMaster main thread

Specified by:
run in interface java.lang.Runnable

tryMasterLock

public boolean tryMasterLock()
                      throws java.io.IOException
Specified by:
tryMasterLock in interface NeptuneMasterIF
Throws:
java.io.IOException

isClusterReady

public static boolean isClusterReady()
                              throws java.io.IOException
ROOT, META가 모두 로딩된 상태

Returns:
Throws:
java.io.IOException

getMasterServerHostName

public static java.lang.String getMasterServerHostName(com.nhncorp.pleiades.client.LockService lockService)
                                                throws java.io.IOException
master가 실행되고 있는 서버 정보를 반환한다.

Parameters:
conf -
Returns:
Throws:
java.io.IOException

format

public static void format()
                   throws java.io.IOException
모든 데이터 및 스키마를 삭제한다.

Throws:
java.io.IOException

formatFileSystem

public static void formatFileSystem(NConfiguration conf)
                             throws java.io.IOException
Throws:
java.io.IOException

doFormat

public static boolean doFormat(NConfiguration conf)
                        throws java.io.IOException
모든 데이터 및 스키마를 삭제한다.

Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Parameters:
args -
Throws:
java.io.IOException

forcedDropTable

public static void forcedDropTable(java.lang.String tableName)
                            throws java.io.IOException
lock, schema 존재여부 상관없이 drop 처리

Parameters:
tableName -
Throws:
java.io.IOException

addColumn

public void addColumn(java.lang.String tableName,
                      java.lang.String addedColumnName)
               throws java.io.IOException
테이블에 컬럼을 추가한다.

Specified by:
addColumn in interface TableManagerProtocol
Throws:
java.io.IOException

addTablet

public TabletInfo addTablet(java.lang.String tableName,
                            Row.Key endRowKey)
                     throws java.io.IOException
Description copied from interface: TableManagerProtocol
테이블에 새로운 Tablet을 추가한다.

Specified by:
addTablet in interface TableManagerProtocol
Returns:
Throws:
java.io.IOException

createTable

public void createTable(TableSchema table,
                        Row.Key[] endRowKeys)
                 throws java.io.IOException
테이블을 생성한다. endRowKeys에 초기에 생성할 tablet에 대한 목록이 있는 경우 tablet을 여러개 생성시키고 그렇지 않는 경우 min ~ max 범위를 저장하는 하나의 tablet만 생성한다.

Specified by:
createTable in interface TableManagerProtocol
Parameters:
table -
endRowKeys -
Throws:
java.io.IOException

assignTablet

public boolean assignTablet(TabletInfo tabletInfo)
                     throws java.io.IOException
Tablet을 tablet server에 할당한다. ignoreFlag는 tablet이 현재 다른 tabletserver에 의해 로딩중이거나 서비스중에 상관없이 지정된 tablet server로 할당된다.

Specified by:
assignTablet in interface TabletMasterProtocol
Returns:
Throws:
java.io.IOException

getAsyncTaskStatus

public AsyncTaskStatus getAsyncTaskStatus(java.lang.String taskId)
                                   throws java.io.IOException
Specified by:
getAsyncTaskStatus in interface AsyncCallProtocol
Throws:
java.io.IOException

removeAsyncTask

public void removeAsyncTask(java.lang.String taskId)
                     throws java.io.IOException
Specified by:
removeAsyncTask in interface AsyncCallProtocol
Throws:
java.io.IOException

dropTable

public java.lang.String dropTable(java.lang.String tableName)
                           throws java.io.IOException
Description copied from interface: TableManagerProtocol
테이블을 drop한다. 테이블 drop 명령의 경우 RPC timeout내에 처리 되지 않기 때문에 async 작업으로 처리된다. 결과 값이 return 되어도 drop 처리가 종료된 것이 아니다.

Specified by:
dropTable in interface TableManagerProtocol
Throws:
java.io.IOException

finalizeDrop

public static java.lang.String finalizeDrop(NeptuneMaster neptuneMaster,
                                            NConfiguration conf,
                                            NeptuneFileSystem fs,
                                            com.nhncorp.pleiades.client.LockService lockService,
                                            java.lang.String tableName,
                                            boolean forced)
                                     throws java.io.IOException
Throws:
java.io.IOException

endTableDrop

public void endTableDrop(java.lang.String taskId,
                         java.lang.String hostName,
                         java.lang.String tableName)
                  throws java.io.IOException
Specified by:
endTableDrop in interface TabletMasterProtocol
Throws:
java.io.IOException

errorTableDrop

public void errorTableDrop(java.lang.String taskId,
                           java.lang.String hostName,
                           java.lang.String tableName,
                           java.lang.String message)
                    throws java.io.IOException
Specified by:
errorTableDrop in interface TabletMasterProtocol
Throws:
java.io.IOException

getTablets

public TabletInfo[] getTablets(java.lang.String tableName)
Description copied from interface: TableManagerProtocol
특정 테이블의 Tablet 목록을 조회한다.

Specified by:
getTablets in interface TableManagerProtocol
Returns:

listTables

public TableSchema[] listTables()
Description copied from interface: TableManagerProtocol
테이블 목록을 조회한다.

Specified by:
listTables in interface TableManagerProtocol
Returns:

endTabletAssignment

public void endTabletAssignment(TabletInfo tabletInfo,
                                boolean created)
                         throws java.io.IOException
Specified by:
endTabletAssignment in interface TabletMasterProtocol
Throws:
java.io.IOException

endTabletAssignmentForHandler

public void endTabletAssignmentForHandler(TabletInfo tabletInfo,
                                          boolean created)
                                   throws java.io.IOException
Proxy를 이용해서 테스트 코드를 작성하기 위해 인터페이스로 빼서 처리, 실제는 endTabletAssignment 처리

Specified by:
endTabletAssignmentForHandler in interface NeptuneMasterIF
Throws:
java.io.IOException

errorTabletAssignment

public void errorTabletAssignment(java.lang.String hostName,
                                  TabletInfo tabletInfo)
Tablet할당 에러 발생시 다음과 같이 처리한다. 1. Tablet을 다른 서버로 이관하는 도중에 발생한 에러의 경우 기존 서버에 stop service가 요청되어 있는 상태인데 stop server를 해제시키고 계속 서비스 하도록한다.cancelStop 요청에도 에러가 발생한 경우 unsigned tablet 목록에 추가한다. 2. 새로 생성된 Tablet인 경우 Tablet을 unsigned tablet 목록에 추가한다.

Specified by:
errorTabletAssignment in interface TabletMasterProtocol

getProtocolVersion

public long getProtocolVersion(java.lang.String protocol,
                               long clientVersion)
                        throws java.io.IOException
Description copied from interface: NVersionedProtocol
Return protocol version corresponding to protocol interface.

Specified by:
getProtocolVersion in interface NVersionedProtocol
Parameters:
protocol - The classname of the protocol interface
clientVersion - The version of the protocol that the client speaks
Returns:
the version that the server will speak
Throws:
java.io.IOException

checkServer

public boolean checkServer()
Specified by:
checkServer in interface TabletMasterProtocol
Returns:

reportTabletSplited

public void reportTabletSplited(TabletInfo targetTablet,
                                TabletInfo[] splitedTablets)
Specified by:
reportTabletSplited in interface TabletMasterProtocol

shutdown

public void shutdown()
Specified by:
shutdown in interface NeptuneMasterIF

isShutdowned

public boolean isShutdowned()
Specified by:
isShutdowned in interface NeptuneMasterIF

reportTabletServerStarted

public void reportTabletServerStarted(java.lang.String hostName)
                               throws java.io.IOException
Description copied from interface: TabletMasterProtocol
네트워크 설정 문제로 Pleiades event handler를 사용하지 못할 경우 TabletServer가 NeptuneMaster로 live 상태를 전송한다.

Specified by:
reportTabletServerStarted in interface TabletMasterProtocol
Throws:
java.io.IOException

getHostName

public java.lang.String getHostName()
Specified by:
getHostName in interface NeptuneMasterIF

getTestHandlerKey

public java.lang.String getTestHandlerKey()
Specified by:
getTestHandlerKey in interface ProxyObject

test

public void test()
Specified by:
test in interface TableManagerProtocol

getConf

public NConfiguration getConf()
Specified by:
getConf in interface NeptuneMasterIF

getTabletServerInfos

public TabletServerInfo[] getTabletServerInfos()
Specified by:
getTabletServerInfos in interface TableManagerProtocol

addUser

public void addUser(java.lang.String userId)
             throws java.io.IOException
Specified by:
addUser in interface TableManagerProtocol
Throws:
java.io.IOException

removeUser

public void removeUser(java.lang.String userId)
                throws java.io.IOException
Specified by:
removeUser in interface TableManagerProtocol
Throws:
java.io.IOException

addTablePermission

public void addTablePermission(java.lang.String tableName,
                               java.lang.String userId,
                               java.lang.String readWrite)
                        throws java.io.IOException
Specified by:
addTablePermission in interface TableManagerProtocol
Throws:
java.io.IOException

removeTablePermission

public void removeTablePermission(java.lang.String tableName,
                                  java.lang.String userId)
                           throws java.io.IOException
Specified by:
removeTablePermission in interface TableManagerProtocol
Throws:
java.io.IOException