メインコンテンツまでスキップ
Version: 3.4.4

Fileエージェント

ノード間のファイル転送をサービスするために、各ノードにインストール運用されるTCP/IPベースのエージェント

エージェントサーバーとクライアント実装に使用されるメッセージプロトコルと詳細な実装事項は、下記の文書を参考にする。下記の文書は、新規APIの作成とサイトカスタマイズのために必要な情報を含む。

Developer documentation : Developer Guide

Installation

Step 1. unpack

プロジェクトBase Directory/distの位置に下記の配布用ファイルが含まれている。

  • bxi-file-agent-1.0.2-prod.tar.bz2
  • bxi-file-agent-1.0.2-prod.tar.gz
  • bxi-file-agent-1.0.2-prod.zip

Agentのサーバーをインストールするためには、配布ファイルを目標システムのインストール位置に圧縮解凍する。 配布ファイルは、インストール位置に下記のディレクトリ構造を作成する。

.
├── bxi-file-agent-1.0.2
│ ├── config
│ │ ├── application.yml
│ │ ├── bxi-file-agent.conf
│ │ ├── custom-context.xml
│ │ ├── logback.xml
│ ├── lib
│ │ └── bxi-file-agent.jar
│ ├── agent-boot.sh
│ ├── agent-boot.bat
│ ├── bxi-file-agent.service.exe
│ ├── bxi-file-agent.service.xml
│ ├── bxi-file-agent.NET2.exe
│ ├── bxi-file-agent.NET4.exe
│ ├── README.md
└───└── DEVELOPER.md
  • application.yml : Agent Server実行のための主な設定ファイル
  • bxi-file-agent.conf : executable jar(bxi-file-agent.jar)ファイルがinit.d Serviceとして登録され実行する時に使用される環境変数ファイル
  • custom-context.xml : 適用環境に合わせてカスタマイズしたBean登録ファイル、spring application context
  • bxi-file-agent.jar : executable jarファイルで実行するために、必要なクラスと依存ライブラリを含む
  • agent-boot.sh : Unix/Linux System環境でcommand lineでAgent Serverを実行するためのシェルファイル
  • agent-boot.bat : Windows System環境でcommand lineでAgent Serverを実行するためのバッチファイル
  • bxi-file-agent.service.exe : Windows SystemにAgent Serverをサービスとして登録するための実行ファイル(= bxi-file-agent.NET4.exe)
  • bxi-file-agent.service.xml : Windows SystemにAgent Serverをサービスとして登録するための設定ファイル
  • bxi-file-agent.NET2.exe : .NET2のみに対応するWindows環境で使用されるサービス登録の実行ファイルで、必要な場合、[bxi-file-agent.service.exe]と名前を変更して使用
  • bxi-file-agent.NET4.exe : .NET4のみに対応するWindows環境で使用されるサービス登録の実行ファイルで、必要な場合、[bxi-file-agent.service.exe]と名前を変更して使用

Step 2. configuration

application.ymlファイルを修正して、Agent Serverを実行するために必要な主設定項目を作成する。ほとんどの場合、すでに作成されている内容をそのまま適用するが、下記に強調されている内容は実行環境に合わせて修正する必要がある。

config/application.yml
spring:
main:
web-application-type: none
banner-mode: "off"
application:
name: BXIFileAgent

logging:
config: config/logback.xml # recommended
level:
root: INFO
org.springframework: INFO
io.netty: INFO
org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener: INFO

context:
location: file:./config # fixed, can not edit

agent:
connect-timeout-millis: 2000
# default 120 min, 要求別にtimeout secondsを保存できるが、これを保存しなかった場合に当該設定を最大許容時間として使用する。
timeout-seconds: 7200
ssl: on
<b>bind: 127.0.0.1 # agent server binding address</b>
<b>tcp-port: 8024 # agent server listen port</b>
boss-count: 1 # thread count for netty server socket
worker-count: 15 # thread count for socket
keep-alive: true
backlog: 100
chunk-size: 1048576 # default 1M bytes
# agent server を起動すると、repositoryの設定項目を検査して保存されているパスを使用できるか確認し、必要な場合はディレクトリを作成する。
validation: on

##################################################################################
#
# <b>repository領域には次の項目を保存する。</b>
# 1. base-dir: 送信するファイルの位置とファイルを保存するための基本パス
# 2. backup-dir: ファイル送信後、バックアップが要求され、要求に対してバックアップ位置を別に保存しなかった場合に使用する基本バックアップパス
# 3. script-dir: クライアントの要求によって要求処理の前後に実行するスクリプト(python)ファイルの位置
# <b>repository下位のsites設定には業務別に基本パスを分離してAgent serverを運用しなければならない場合
# パスの集合をsite別に保存する。</b>
#
##################################################################################

repository:
<b>base-dir: /home/fileagent/data/agent</b>
backup-dir: ${agent.repository.base-dir}/backup
script-dir: ${agent.repository.base-dir}/scripts
sites:
biz1: # unique id of site
name: siteOfBiz1
base-dir: ${agent.repository.base-dir}/biz1
backup-dir: ${agent.repository.base-dir}/biz1/backup
script-dir: ${agent.repository.base-dir}/biz1/scripts
biz2: # unique id of site
name: siteOfBiz2
base-dir: ${agent.repository.base-dir}/biz2
backup-dir: ${agent.repository.base-dir}/biz2/backup
script-dir: ${agent.repository.base-dir}/biz2/scripts
biz3: # unique id of site
name: siteOfBiz3
base-dir: ${agent.repository.base-dir}/biz3
backup-dir: ${agent.repository.base-dir}/biz3/backup
script-dir: ${agent.repository.base-dir}/biz3/scripts

# fixed, can not edit below lines
management:
endpoint:
shutdown:
enabled: true

Usage

Agent serverは、command lineまたはシステムサービス形式で実行できる。配布されたパッケージには、運用環境によって使用できるcommand line control(start, stop, status) scriptと、システムサービスとして登録して運用する時に使用できるツールが含まれている。

Logging

インストールされたAgent Serverが実行されると、インストール位置の下位にlogsディレクトリが作成され、bxi-file-agent.logログファイルと制御のために必要な.lock.pidファイルが作成される。 実行時に発生する情報は、ログファイルで確認できる。 作成されるログファイルは日別にrollingされる。 ログファイルの位置とレベルはconfig/application.ymlファイルを修正して下記のように、変更できる。

config/application.yml
logging:
config: config/logback.xml # recommended
level:
root: DEBUG
org.springframework: INFO
io.netty: INFO
org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener: INFO

Microsoft Windows Operating System

Command Line Control

配布されたパッケージには、Command LineでAgent Serverを運用できるようにWindows環境に必要なagent-boot.batファイルが含まれている。

  • Agent Serverを開始するためには、Windowsが提供するCommand Prompt (CMD)を利用してインストール位置に移動し、以下のCommandを実行する。
agent-boot.bat start
  • 次のCommandを利用して、実行中のAgent Serverの状態を確認できる。
agent-boot.bat status
  • 実行中のAgent Serverは、下記のCommandを利用して中止する。
agent-boot.bat stop

Windows System Service

配布されたパッケージは、Windows System ServiceでAgent Serverを登録して運用できるように、システムサービス登録とテスト、登録解除に使用される以下のファイルを含む。

  • bxi-file-agent.NET2.exe
  • bxi-file-agent.NET4.exe
  • bxi-file-agent.service.exe
  • bxi-file-agent.service.xml

  1. install

実行ファイルを利用して、Agent ServerをWindows System Serviceに登録する。

bxi-file-agent.service.exe install

目標システムが.NET4に対応しない場合、含まれているbxi-file-agent.NET2.exeファイルを利用する。 この時には、ファイル名をbxi-file-agent.service.exeに変更する必要がある。 サービス登録が正常完了すると、コントロール パネル->管理ツール->サービスから正常登録するかどうかを確認できる。

下記のサービス登録に使用される設定ファイルbxi-file-agent.service.xmlの内容である。

<service>
<id>Bxi-file-agent</id>
<name>Bxi-file-agent</name>
<description>This service runs bxi file agent.</description>
<env name="AGENT_HOME" value="%BASE%"/>
<executable>java</executable>
<arguments>-XX:+UseG1GC -Xms1024m -Xmx4096m -jar "%BASE%\lib\bxi-file-agent.jar" --spring.config.location=%BASE%\config\application.yml --context.location=file:%BASE%\config --logging.file=%BASE%\logs\bxi-file-agent.log</arguments>
<workingdirectory>%BASE%</workingdirectory>
<stoptimeout>5 sec</stoptimeout>
<startmode>Automatic</startmode>
<delayedAutoStart/>
<logpath>%BASE%\logs</logpath>
<logmode>rotate</logmode>
</service>

設定ファイルにstartModeAutomaticに基本設定されており、<delayedAutoStart/>項目が指定されているため、Agent Server ServiceはWindow System開始とともに遅延開始される。 startModeはBoot、System、Automatic、Manualに変更指定できる。

  1. uninstall

実行ファイルを利用して登録されているAgent Serverを除去できる。

bxi-file-agent.service.exe uninstall
  1. start / stop / restart

Agent ServerがWindows System Serviceに登録後は、startModeの指定によって開始条件に従って開始される。 正常に動作するかどうかを確認するためにテストが必要な場合、下記のように、Serviceを開始するか、中断することができる。

bxi-file-agent.service.exe start
bxi-file-agent.service.exe stop
bxi-file-agent.service.exe restart
  1. status

下記のコマンドを利用してAgent Serverのサービス登録するかどうかと実行状態を確認できる。

bxi-file-agent.service.exe status
  • nonExistent : サービスに登録されていない
  • Started : サービスが開始される
  • Stopped : 登録されたサービスが中断されたり、実行中ではない

Unix/Linux Operating System

Command Line Control

配布されたパッケージにはCommand LineでAgent Serverを運用できるようにUnix/Linux環境に必要なagent-boot.shファイルが含まれている。

  • Agent Serverを開始するためには、インストール位置に移動してから下記のCommandを実行する。
agent-boot.sh start
  • 次のCommandを利用して、実行中のAgent Serverの状態を確認できる。
agent-boot.sh status
  • 実行中のAgent Serverは、下記のCommandを利用して中止する。
agent-boot.sh stop

Installation as an init.d Service (System V)

配布されたパッケージのlib/bxi-file-agent.jarファイルはfully executable jar形式でビルドされているため、symbolic linkを作成してSystem Serviceとして登録され実行できる。 サービス登録のために、root権限で下記のように、symbolic linkを作成する。

sudo ln -s ${Replace with actual installation location}/lib/bxi-file-agent.jar /etc/init.d/bxi-file-agent

サービス登録後は、下記のように、Agent Serverを制御することができる。

service bxi-file-agent {start|stop|force-stop|restart|force-reload|status|run}

Environment variables

Agent Serverパッケージは、様々な実行環境を提供することによって、JVMに環境変数を伝達する様々な種類の設定ファイルが使用される。 しかし、JVMが始まってからAgent Serverに適用されるすべての設定項目はconfig/application.ymlに含まれる。

下記は、実行方法によってmaximum heap sizeなどを修正したり、JVM実行オプションを追加する必要がある場合、変更する項目を並べる。

  • Windows Command Line : JAVA_OPTS variable in agent-boot.bat
  • Windows System Service : arguments element in bxi-file-agent.service.xml、reinstall required
  • Unix/Linux Command Line : JAVA_OPTS variable in agent-boot.bat
  • Unix/Linux System Service : JAVA_OPTS variable in bxi-file-agent.conf、reinstall not required