nd4j-parameter-server-parent/nd4j-parameter-server-status/src/main/java/org/nd4j/parameterserver/status/play/StatusServer.java
public static Server startServer(StatusStorage statusStorage, int statusServerPort) {
        log.info("Starting server on port " + statusServerPort);
        RoutingDsl dsl = new RoutingDsl();
        dsl.GET("/ids/").routeTo(new F.Function0<Result>() {

            @Override
            public Result apply() throws Throwable {
                List<Integer> ids = statusStorage.ids();
                return ok(toJson(ids));
            }
        });


        dsl.GET("/state/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return ok(toJson(statusStorage.getState(Integer.parseInt(id))));
            }
        });

        dsl.GET("/opType/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return ok(toJson(ServerTypeJson.builder()
                                .type(statusStorage.getState(Integer.parseInt(id)).serverType())));
            }
        });


        dsl.GET("/started/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return statusStorage.getState(Integer.parseInt(id)).isMaster()
                                ? ok(toJson(MasterStatus.builder()
                                                .master(statusStorage.getState(Integer.parseInt(id)).getServerState())
                                                //note here that a responder is is + 1
                                                .responder(statusStorage
                                                                .getState(Integer.parseInt(id) + 1).getServerState())
                                                .responderN(statusStorage
                                                                .getState(Integer.parseInt(id)).getTotalUpdates())
                                                .build()))
                                : ok(toJson(SlaveStatus.builder()
                                                .slave(statusStorage.getState(Integer.parseInt(id)).serverType())
                                                .build()));
            }
        });



        dsl.GET("/connectioninfo/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return ok(toJson(statusStorage.getState(Integer.parseInt(id)).getConnectionInfo()));
            }
        });

        dsl.POST("/updatestatus/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                SubscriberState subscriberState = Json.fromJson(request().body().asJson(), SubscriberState.class);
                statusStorage.updateState(subscriberState);
                return ok(toJson(subscriberState));
            }
        });

        Server server = Server.forRouter(dsl.build(), Mode.PROD, statusServerPort);

        return server;

    }
public static Server startServer(StatusStorage statusStorage, int statusServerPort) {
        log.info("Starting server on port " + statusServerPort);
        RoutingDsl dsl = new RoutingDsl();
        dsl.GET("/ids/").routeTo(new F.Function0<Result>() {

            @Override
            public Result apply() throws Throwable {
                List<Integer> ids = statusStorage.ids();
                return ok(toJson(ids));
            }
        });


        dsl.GET("/state/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return ok(toJson(statusStorage.getState(Integer.parseInt(id))));
            }
        });

        dsl.GET("/opType/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return ok(toJson(ServerTypeJson.builder()
                                .type(statusStorage.getState(Integer.parseInt(id)).serverType())));
            }
        });


        dsl.GET("/started/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return statusStorage.getState(Integer.parseInt(id)).isMaster()
                                ? ok(toJson(MasterStatus.builder()
                                                .master(statusStorage.getState(Integer.parseInt(id)).getServerState())
                                                //note here that a responder is is + 1
                                                .responder(statusStorage
                                                                .getState(Integer.parseInt(id) + 1).getServerState())
                                                .responderN(statusStorage
                                                                .getState(Integer.parseInt(id)).getTotalUpdates())
                                                .build()))
                                : ok(toJson(SlaveStatus.builder()
                                                .slave(statusStorage.getState(Integer.parseInt(id)).serverType())
                                                .build()));
            }
        });



        dsl.GET("/connectioninfo/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                return ok(toJson(statusStorage.getState(Integer.parseInt(id)).getConnectionInfo()));
            }
        });

        dsl.POST("/updatestatus/:id").routeTo(new F.Function<String, Result>() {
            @Override
            public Result apply(String id) throws Throwable {
                SubscriberState subscriberState = Json.fromJson(request().body().asJson(), SubscriberState.class);
                statusStorage.updateState(subscriberState);
                return ok(toJson(subscriberState));
            }
        });

        Server server = Server.forRouter(dsl.build(), Mode.PROD, statusServerPort);

        return server;

    }
public static Server startServer ( StatusStorage statusStorage , int statusServerPort ) { log . info ( "Starting server on port " + statusServerPort ) ; RoutingDsl dsl = new RoutingDsl ( ) ; dsl . GET ( "/ids/" ) . routeTo ( new F . Function0 < Result > ( ) { @ Override public Result apply ( ) throws Throwable { List < Integer > ids = statusStorage . ids ( ) ; return ok ( toJson ( ids ) ) ; } } ) ; dsl . GET ( "/state/:id" ) . routeTo ( new F . Function < String , Result > ( ) { @ Override public Result apply ( String id ) throws Throwable { return ok ( toJson ( statusStorage . getState ( Integer . parseInt ( id ) ) ) ) ; } } ) ; dsl . GET ( "/opType/:id" ) . routeTo ( new F . Function < String , Result > ( ) { @ Override public Result apply ( String id ) throws Throwable { return ok ( toJson ( ServerTypeJson . builder ( ) . type ( statusStorage . getState ( Integer . parseInt ( id ) ) . serverType ( ) ) ) ) ; } } ) ; dsl . GET ( "/started/:id" ) . routeTo ( new F . Function < String , Result > ( ) { @ Override public Result apply ( String id ) throws Throwable { return statusStorage . getState ( Integer . parseInt ( id ) ) . isMaster ( ) ? ok ( toJson ( MasterStatus . builder ( ) . master ( statusStorage . getState ( Integer . parseInt ( id ) ) . getServerState ( ) ) //note here that a responder is is + 1 . responder ( statusStorage . getState ( Integer . parseInt ( id ) + 1 ) . getServerState ( ) ) . responderN ( statusStorage . getState ( Integer . parseInt ( id ) ) . getTotalUpdates ( ) ) . build ( ) ) ) : ok ( toJson ( SlaveStatus . builder ( ) . slave ( statusStorage . getState ( Integer . parseInt ( id ) ) . serverType ( ) ) . build ( ) ) ) ; } } ) ; dsl . GET ( "/connectioninfo/:id" ) . routeTo ( new F . Function < String , Result > ( ) { @ Override public Result apply ( String id ) throws Throwable { return ok ( toJson ( statusStorage . getState ( Integer . parseInt ( id ) ) . getConnectionInfo ( ) ) ) ; } } ) ; dsl . POST ( "/updatestatus/:id" ) . routeTo ( new F . Function < String , Result > ( ) { @ Override public Result apply ( String id ) throws Throwable { SubscriberState subscriberState = Json . fromJson ( request ( ) . body ( ) . asJson ( ) , SubscriberState . class ) ; statusStorage . updateState ( subscriberState ) ; return ok ( toJson ( subscriberState ) ) ; } } ) ; Server server = Server . forRouter ( dsl . build ( ) , Mode . PROD , statusServerPort ) ; return server ; }
Start a server based on the given subscriber.
Note that for the port to start the server on, you should
set the statusServerPortField on the subscriber
either manually or via command line. The
server defaults to port 9000.

The end points are:
/opType: returns the opType information (master/slave)
/started: if it's a master node, it returns master:started/stopped and responder:started/stopped
/connectioninfo: See the SlaveConnectionInfo and MasterConnectionInfo classes for fields.
/ids: the list of ids for all of the subscribers
@param statusStorage the subscriber to base
the status server on
@return the started server
Start a server based on the given subscriber . Note that for the port to start the server on you should set the statusServerPortField on the subscriber either manually or via command line . The server defaults to port 9000 .