5

私は Akka ベースのサーバーを開発し、マイクロカーネルのアイデアが気に入りました。ただし、Java と Mavenを使用して実装の詳細を見ると、スタートアップ スクリプトを記述する必要がないことを約束するフレームワーク固有のソリューションと単純な Java メイン スタートアップ クラスを交換しています。

  • Akka がインストールされている (Akka がインストールされていなくても、ライブラリのみを使用して作業できます)
  • Maven 関連の追加の 2 つの変更と、追加のアセンブリ アーティファクトが必要です
  • 「開始」スクリプトも必要なので、ポイントは何ですか?

多分私は何かを逃していますか?しかし、単純な古い Java のメイン ソリューションと比較して、より簡単なセットアップや利点は見られません。

更新:答えを得た後、もう少し考えてください。将来的に Akka コンソール経由で開始できるように、マイクロカーネルの観点からメイン クラスを記述する良いケースがまだある可能性があります。

public class MapReduceServer implements Bootable {
    //---------------------------------------------------------------
    // public
    //---------------------------------------------------------------
    /**
     * Default constructor simply initializes the system.
     */
    public MapReduceServer() {
        system = ActorSystem.create("MapReduceApp", ConfigFactory.
                load().getConfig("MapReduceApp"));
    }

    //---------------------------------------------------------------
    /**
     * {@inheritDoc}
     */
    @Override
    public void startup() {
        // create the list of reduce Actors
        ActorRef reduceActor = system.actorOf(Props.create(ReduceActor.class)
                .withRouter(new FromConfig()), "reduceActor");

        // create the list of map Actors
        ActorRef mapActor = system.actorOf(Props.create(MapActor.class, reduceActor).
                withRouter(new FromConfig()), "mapActor");

        // create the overall Master Actor that acts as the remote actor for clients
        @SuppressWarnings("unused")
        ActorRef masterActor = system.actorOf(
                Props.create(MapReduceMasterActor.class, mapActor), "masterActor");
    }

    //---------------------------------------------------------------
    /**
     * {@inheritDoc}
     */
    @Override
    public void shutdown() {
        system.shutdown();
    }

    //---------------------------------------------------------------
    /**
     * Main method
     *
     * @param args
     */
    public static void main(String[] args) {
        MapReduceServer mapReduceServer = null;

        LOGGER.info("starting ...");
        mapReduceServer = new MapReduceServer();
        mapReduceServer.startup();
        LOGGER.info("done");
    }
4

2 に答える 2