Giter Club home page Giter Club logo

ml-app-deployer's Introduction

What is ml-app-deployer?

ml-app-deployer is a Java library that provides two capabilities:

  1. A client library for the new Management REST API in MarkLogic 8.
  2. A command-driven approach for deploying and undeploying an application to MarkLogic that depends on the management client library.

If you're just looking for a Java library for interacting with the Management REST API, you can certainly use ml-app-deployer. The deployer/command library is mostly a thin layer around the management client library and can be safely ignored if you don't need it.

Javadocs for ml-app-deployer are here.

What does it depend on?

ml-app-deployer depends on MarkLogic 8 and Java 1.7+.

Under the hood, it depends on Spring's RestTemplate for interacting with the Management REST API. It also depends on ml-javaclient-util for loading modules, which is done via the MarkLogic Client REST API.

How do I start using the client library?

The general pattern for using the management client library is:

  1. Create an instance of ManageConfig, which specifies connection information for the management REST API instance.
  2. Create an instance of ManageClient using ManageConfig. ManageClient simply wraps a RestTemplate with some convenience methods.
  3. Using ManageClient, create a Manager class based on the management resource you want to configure. For example, to create or modify or delete a database, create a DatabaseManager to talk to the database endpoints.

Here's a brief example of what that looks like:

ManageConfig config = new ManageConfig(); // defaults to localhost/8002/admin/admin
ManageClient client = new ManageClient(config);
DatabaseManager dbMgr = new DatabaseManager(client);
dbMgr.save("{\"database-name\":\"my-database\"}");

How do I start using the deployer library?

The main concept behind the deployer library is invoke a series of commands, where each command looks for one or more configuration files in a specific directory structure and then uses a Manager class in the client library to apply those configuration files as part of deploying an application.

The best way to understand that directory is to look at the sample-app application that's used by the JUnit tests. The concept is fairly simple - within the ml-config directory, there's a directory for each of the top-level resources defined by the Management API docs. Thus, database config files are found under "databases", while scheduled task config files are found under "scheduled-tasks". Some directories have subdirectories based on how the Management API endpoints are defined - for example, the "security" directory has child directories of "amps", "roles", "users", and others based on the resources that comprise the "security" set of endpoints.

The logic for when to look for files is encapsulated in Command objects. A deployment is performed by one or more Command objects. Thus, the general pattern for using the deployer library is:

  1. Create an instance of SimpleAppDeployer, which implements the AppDeployer interface
  2. Set a list of commands on the SimpleAppDeployer instance
  3. Call the "deploy" method to invoke each of the commands in a specific order

Here's a brief example of what that looks like - note that we'll reuse our ManageClient from above, and we'll deploy an application that needs to create a REST API server named "my-app" on port 8123 and create some users too - the config for both of those will be read from files in the ml-config directory structure:

ManageClient client = new ManageClient(); // defaults to localhost/8002/admin/admin
AdminManager manager = new AdminManager(); // used for restarting ML; defaults to localhost/8001/admin/admin
AppDeployer deployer = new SimpleAppDeployer(client, manager, 
    new DeployRestApiServersCommand(), new DeployUsersCommand());

// AppConfig contains all configuration about the application being deployed
AppConfig config = new AppConfig(); 
config.setName("my-app");
config.setRestPort(8123);

// Calls each command, passing the AppConfig and ManageClient to each one
deployer.deploy(config); 

// do some other stuff...

// Calls each command, giving each a chance to undo what it did before
deployer.undeploy(config); 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.