Skip to content

Latest commit

 

History

History
311 lines (221 loc) · 9.77 KB

README-ja.md

File metadata and controls

311 lines (221 loc) · 9.77 KB

CF-Abacus

Abacusはメータリングと集計のためのサービスです。

概要

AbacusはCloud Foundry (CF) のための利用量の計測と集計機能を提供します。 これらはすべてRESTのマイクロサービスとして実装され、Cloud Foundryの組織に閉じた複数のレベルに置ける、利用ログの集約、メータリング方式の適用、および集計機能を提供します。

AbacusはNode.jsで実装されており、さまざまなマイクロサービスがCFアプリとして動きます。

Abacusはクラウドサービスプロバイダに対して、利用データを登録するためのREST APIを提供します。また、利用量ダッシュボードや、利用量レポートをダウンロードするための課金システムなどを作成するためのREST APIを提供します。Abacus REST APIの詳細はdoc/api-ja.mdを参照してください。

よくある質問(FAQ)

AbacusのFAQはdoc/faq-ja.mdに記載されています。

ビルド方法

Abacusは、npm 2.10.1以上、Node.js 0.10.36以上が必要です。

cd cf-abacus

# Bootstrap the build environment
# install the Node.js module dependencies and run the tests
npm run build

テスト方法

cd cf-abacus

# Run eslint on the Abacus modules
npm run lint

# Run the tests
npm test

Cloud Foundryへのデプロイ

Abacusは、Cloud Foundryにデプロイされた一式のアプリケーションとして動きます。それぞれのアプリケーションは可用性・性能を考慮して複数のインスタンス上で動作するように設定できます。サービス利用データはCouchDBに保存されます。

この図はAbacusアプリケーションと、利用量を処理する際のロールについて記載したものです。

Abacus flow diagram

下記のステップはBosh-liteを用いてローカルのCloud Foundry環境にデプロイし、Bosh-lite CFのインストールスクリプトによってデフォルトのローカルIP 10.244.0.34が割り振られ、CF v210でテストされることを想定しています。適宜、利用するCloud Foundry環境に読み替えて下さい。

cd cf-abacus

# Point CF CLI to your local Cloud Foundry deployment and
# create a CF security group for the Abacus apps
bin/cfsetup

# Run cf push on the Abacus apps to deploy them to Cloud Foundry
npm run cfpush

# Check the state of the Abacus apps
cf apps

# You should see something like this
Getting apps in org <your organization> / space <your space>...
OK

name                       requested state   instances   memory   disk   urls   
abacus-usage-collector     started           1/1         512M     512M   abacus-usage-collector.10.244.0.34.xip.io   
abacus-usage-meter         started           1/1         512M     512M   abacus-usage-meter.10.244.0.34.xip.io
abacus-usage-accumulator   started           1/1         512M     512M   abacus-usage-accumulator.10.244.0.34.xip.io   
abacus-usage-aggregator    started           1/1         512M     512M   abacus-usage-aggregator.10.244.0.34.xip.io   
abacus-usage-reporting     started           1/1         512M     512M   abacus-usage-reporting.10.244.0.34.xip.io   
abacus-provisioning-plugin started           1/1         512M     512M   abacus-provisioning-plugin.10.244.0.34.xip.io   
abacus-account-plugin      started           1/1         512M     512M   abacus-account-plugin.10.244.0.34.xip.io   
abacus-pouchserver         started           1/1         1G       512M   abacus-pouchserver.10.244.0.34.xip.io   

Cloud Foundry上でのデモの実行

The Abacus demo runs a simple test program that simulates the submission of usage by a Cloud service provider, then gets a daily report for the usage aggregated within a Cloud Foundry organization.

The demo data is stored in a small in-memory PouchDB test database so the demo is self-contained and you don't need to set up a real CouchDB database just to run it.

Once the Abacus apps are running on your Cloud Foundry deployment, do this:

cd cf-abacus

# Run the demo script
npm run demo -- \
  --collector https://abacus-usage-collector.10.244.0.34.xip.io \
  --reporting https://abacus-usage-reporting.10.244.0.34.xip.io

# You should see usage being submitted and a usage report for the demo organization

localhostでのAbacusの実行

The Abacus apps can also run on your local host in a shell environment outside of Cloud Foundry, like this:

cd cf-abacus

# Start the Abacus apps
npm start

# Wait a bit until all the apps have started

# Run the demo script
npm run demo

# Stop everything
npm stop

Cloud Foundryアプリケーションの利用量集計

Abacus comes with a CF bridge that acts as a resource provider for Cloud Foundry app runtime usage, reads Cloud Foundry app usage events and reports usage to the Abacus usage collector.

In the end the Abacus CF bridge enables you to see runtime usage reports for the apps running on your Cloud Foundry instance. In order to start the bridge follow its README.

レイアウト

The Abacus source tree is organized as follows:

bin/ - Start, stop, demo and cf push scripts

demo/ - Demo apps

    client - demo program that posts usage and gets a report

doc/ - API documentation

lib/ - Abacus modules

    metering/ - Metering services

        collector - receives and collects service usage data
        meter     - applies metering formulas to usage data

    aggregation/ - Aggregation services

        accumulator - accumulates usage over time and applies
                      pricing to accumulated usage
        aggregator  - aggregates usage within an organization and applies
                      pricing to aggregated usage
        reporting   - returns usage reports

    cf/ - CF platform integration

        bridge - collects CF app usage data

    config/ - Usage formula and pricing configuration

    utils/ - Utility modules used by the above

    plugins/ - Plugins for provisioning and account services

test/ - End to end tests

    perf/ - Performance tests

tools/ - Build tools

etc/ - Misc build scripts

Developing individual Abacus modules

As shown in the above Layout section, Abacus consists of a number of Node.js modules under the lib directory.

When developing on Abacus you may want to quickly iterate through changes to a single module, and run the tests only for that module rather than rebuilding the whole project each time.

Here are the steps most of us follow when we work on a single module, using the collector module as an example.

First, bootstrap your Abacus development environment:

cd cf-abacus

# Setup the base Node.js tools and dependencies used by the Abacus build
npm run bootstrap

Then install your module's dependencies as usual with npm:

cd cf-abacus/lib/metering/collector
npm install

At this point your development cycle boils down to:

cd cf-abacus/lib/metering/collector

# Run ESLint on your code and run the module's unit tests
npm test

To run the collector app you can do this:

cd cf-abacus/lib/metering/collector
npm start

To push the app to your Cloud Foundry instance, do this:

cd cf-abacus/lib/metering/collector
npm run cfpush

Finally, to rebuild everything once you're happy with your module:

cd cf-abacus

# Important to do at this point as the next step does a git clean
git add <your changes>

# Does a git clean to make sure the build starts fresh
npm run clean

# Build and unit test all the modules
npm run build

# Or to run what our Travis-CI build runs, including integration tests
npm run cibuild

People

List of all contributors

License

Apache License 2.0 )